Spring加载**.properties失败的问题

小弟刚刚接触spring。打算自己建立一个工程。在创建过程中遇到一个问题,如下:
工程结构:
图片说明
web.xml引入子工程配置:
图片说明
mq-demo-consumer.xml里面引入文件配置如下:
图片说明
spring-config.xml里面引入配置文件如下:
图片说明
其中spring-datasources.xml 文件引入:

mq-inputpiece-api.xml文件引入:

所有的**.properties文件都在
图片说明
编译之后class文件:
图片说明
可以看到所有的**.properties已经都在classes路径下。
具体问题是:
web.xml的配置的

contextConfigLocation

<!--classpath*:spring-config.xml,-->
classpath*:mq-demo-consumer.xml,
classpath*:spring-config.xml,
<!--classpath*:spring-redis.xml,-->
classpath*:spring-shiro.xml;


如果屏蔽mq-demo-consumer.xml则系统正常。如果引入mq-demo-consumer.xml则spring-config.xml里面配置的数据库问题提示找不到**.properties里面的配置项。如果把spring-config.xml 放到 mq-demo-consumer.xml之前则mq-demo-consumer.xml里面配置的mq-inputpiece-api.xml里面找不到rabbitmq.properties里面的配置项。查看spring加载日志发现只有写在web.xml里面前面的xml文件可以引入**.propert。后面的文件无法引入
.xml里面配置的.properties

7个回答

去看看《Spring实战》,试试用Java配置吧,另外你可以把你的工程打包发到百度云,这样方便帮你处理问题。

PropertyPlaceholderConfigurer类的方式在spring的配置文件中只有一个起作用,即,假如都配置了,只有最先配置的才会被配置文件加载到,

http://lib.csdn.net/my/structure/spring 看下这个吧。应该对你有帮助。

yaohx123
yaohx123 不存在了
一年多之前 回复

我接触过的工程确实是都将properties文件放到web.xml中引用的

u010279664 是第一个回答问题的。帮我解决了问题,但是没有说明具体配置。贴出一个配置希望对大家有帮助

yaohx123
yaohx123 <context:property-placeholder location="classpath:*.properties" order="0" ignore-resource-not-found="false"/>
一年多之前 回复

classpath*:mq-demo-consumer.xml,spring-config.xml这样吧

和配置PropertyPlaceholderConfigurer类的方式在spring的配置文件中只有一个起作用,即,假如都配置了,只有最先配置的才会被配置文件加载到,因为spring容器采用反射扫描机制,如果已经有一个PropertyPlaceholderConfigurer类的实例,那么就不会再创建了,因此使用其中一种方式即可

qq_41612035
qq_41612035 和配置PropertyPlaceholderConfigurer类的方式在spring的配置文件中只有一个起作用,即,假如都配置了,只有最先配置的才会被配置文件加载到,因为spring容器采用反射扫描机制,如果已经有一个PropertyPlaceholderConfigurer类的实例,那么就不会再创建了,因此使用其中一种方式即可
一年多之前 回复
caozhy
贵阳老马马善福专门编写代码的老马就是我! 请管理员注意封杀这个胡乱抄袭的垃圾用户。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Spring| Spring 加载和使用properties配置文件
文章目录1.让Spring加载管理properties文件2.在Spring中使用properties文件内容3.相关配置说明 1.让Spring加载管理properties文件 基于注解的方式 可以使用Environment来获取配置信息,也可以参考第二点中的使用方式. PropertySource注解的value是String[],支持配置多个properties文件. @Configura...
spring 配置加载properties属性文件
1. spring 配置&amp;lt;context:property-placeholder/&amp;gt; 作用说明: -(property-placeholder)属性占位符,就是加载properties资源文件 在xml文件中可以用 ${属性key}获取value; - 在spring管理的javabean中也可以获取-&amp;gt; @Value(“属性key”) String xx; - localtioin属性可
Spring 加载 *.properties 文件的源码分析
Spring 是如何加载 *.properties 文件的?1、属性加载器PropertyPlaceholderConfigurer.java 类图结构 通过类图,我们可以看到,PropertyPlaceholderConfigurer 实现了 BeanFactoryPostProcessor 接口,该接口中只有一个接口方法,通过方法注释我么可以了解到: (1)、该接口的可有在 bean 实例化
spring同时加载多个properties
java加载properties文件的方法 http://blog.csdn.net/u011063151/article/details/51888640 spring的xml加载properties文件 https://www.cnblogs.com/shanheyongmu/p/5806872.html 需要同时加载多个properties,上面基本没有借鉴的地方,重新写了一个
读取spring加载的properties的值
代码来自网络,测试有效 package com.cqjk.util; import java.lang.reflect.Method; import java.util.Properties; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; import org.springfr...
spring properties配置文件加载源码分析
一、spring 中读取properties 配置文件的几种方式 1.使用&amp;lt;context:property-placeholder &amp;gt; 标签 &amp;lt;context:property-placeholder location=&quot;classpath:properties/ee.properties&quot; /&amp;gt; 2.创建 PropertySourcesPlaceholderConfi...
spring在加载properties时出现的问题
在spring.xml中将redis.properties Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dsd' defined in class path resource [spring
请教一个关于spring加载properties的问题。
我在spring配置中配置了 PropertyPlaceholderConfigurerrn rn rn rn classpath:xxxx.propertiesrn rn rn rnrn在其他地方使用$xx.xxx来读取properties中的内容。rn而且我需要在网页上修改xxxx.properties的内容,然后保存,并且希望在以后加载bean的时候使用修改后的属性。rnrn现在的问题是,我一修改保存xxxx.properties,spring就去重新加载所有的bean,几百个,搞半天,但是实际上只影响到几个bean而已,请问这个问题怎么解决啊。
weblogic加载spring失败
环境: liunx weblogic9.2.4 jrokit1.5,发布应用失败,报如下错误。rn配置文件如下:rn[code=XML]rnrn cn.easyuda.framework.startup.impl.StartUpWithMessageImplrn rn rn WEB-INF/custom/spring/beanfactory-common.vmrn WEB-INF/custom/metadata/meta-dictionarys.xmlrn WEB-INF/custom/metadata/meta-domains.xmlrn WEB-INF/custom/metadata/meta-individual-cutomer-base-info.xmlrn WEB-INF/custom/metadata/meta-role.xmlrn WEB-INF/custom/spring/loan.validator.xml rn WEB-INF/custom/spring/loan.page.mapping.remind.xmlrn rn rn GB2312rn rn 0rn rnrn rn cn.easyuda.framework.dynamic.loader.JarFileLoaderrn rn WEB-INF/lib/uda-business.jarrn com.git.loanrn rn UCC.classrn 1rn rnrn rn cn.easyuda.framework.dynamic.loader.PlainFileLoaderrn rn /WEB-INF/facesrn rn .xmlrn 1rn rnrn rn cn.easyuda.framework.dynamic.loader.PlainFileLoaderrn rn /WEB-INF/tilesrn rn .xmlrn 1rn rn[/code]rn加载到报以下错误。rnrn[code=Java][2012-10-13 15:19:39,983]-INFO (StartUpSpringImpl.java:38)|::Spring配置工厂初始化失败::rnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.easyuda.framework.logic.cmdexecutor.impl.PlainProxyExecutor.proxy' defined in resource loaded from byte array: Cannot resolve reference to bean 'weblogicJtaTransactionManager' while setting bean property 'transactionManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'weblogicJtaTransactionManager' defined in resource loaded from byte array: Invocation of init method failed; nested exception is org.springframework.transaction.TransactionSystemException: JTA TransactionManager is not available at JNDI location [javax/transaction/TransactionManager]; nested exception is javax.naming.AuthenticationException [Root exception is javax.security.auth.login.FailedLoginException: [Security:090304]Authentication Failed: User weblogic javax.security.auth.login.FailedLoginException: [Security:090302]Authentication Failed: User weblogic denied]rn at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:275)rn at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:104)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1245)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1010)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)rn at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:423)rn at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:730)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:381)rn at cn.easyuda.framework.startup.impl.StartUpSpringImpl.start(StartUpSpringImpl.java:36)rn at cn.easyuda.framework.startup.impl.StartUpWithMessageImpl.start(StartUpWithMessageImpl.java:20)rn at cn.easyuda.framework.StartUpListener.contextInitialized(StartUpListener.java:38)rn at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:376)rn at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)rn at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)rn at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:82)rn at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1622)rn at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2790)rn at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:889)rn at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:329)rn at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:205)rn at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)rn at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)rn at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:201)rn at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:118)rn at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:205)rn at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)rn at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)rn at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:27)rn at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:636)rn at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)rn at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)rn at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)rn at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)rn at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:566)rn at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:136)rn at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:104)rn at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:139)rn at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:320)rn at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:815)rn at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1222)rn at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:433)rn at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:162)rn at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:181)rn at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)rn at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)rn at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)rn at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)rn at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)[/code]
关于加载Spring加载外部文件属性.properties的问题
关于加载Spring加载外部文件属性.properties的问题 如果你今天遇到和我一样的问题,那么我恭喜你,你已经知道答案了。 第一个错误:Exception in thread "main" org.springframework.beans.factory. xml.XmlBeanDefinitionStoreException:  Line 1 in XML document fr
spring properties问题,急~~~
用spring读取properties,出错:rndataSource_config.xml:rnrn rn rn file:conf/DB.propertiesrn rn rn rn GBKrn rnrnrn rn rn rn rn rn rnrnrnDB.properties文件:rnit.db.jdbcUrl=jdbc:oracle:thin:@192.168.35.207:1521:orclrnit.db.driverClass=oracle.jdbc.driver.OracleDriverrnit.db.userName=cnmscfgrnit.db.password=ffcsossrnrn报错信息如下:rnException in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definition with name 'dataSource' defined in file [G:\MyWorkSpace\ITResourceManager\conf\dataSource_config.xml]: Could not resolve placeholder 'it.db.driverClass'rnrn驱动包什么的都加了,没用properies之前测试过,可以运行,加了之后就出错了,求高手解决
Spring加载Properties配置文件的四种方式
Spring加载Properties配置文件的四种方式一、通过 context:property-placeholder 标签实现配置文件加载1、用法示例: 在spring.xml配置文件中添加标签 2、在 spring.xml 中使用配置文件属性: ${jdbc.url}" /> ${jdbc.username}" /> ${jdbc.password}" />
spring项目中加载资源配置文件(*.properties)
关于加载配置文件,一种方法是写一个工具类读取资源文件,参考如下: https://blog.csdn.net/u012027874/article/details/53809964 第二种方法是利用spring容器加载特性再通过注解去获取,步骤如下: 首先在spring容器中加载配置文件: &amp;lt;context:property-placeholder location=&quot;classpa...
Spring加载Properties配置文件的几种方式
一:通过context:property-placeholder标签实现配置文件加载 在spring的配置文件中添加如下声明 &lt;context:property-placeholder ignore-unresolvable="true" location="classpath:jdbc.properties"/&gt; 引用值时,注意使用$引用需要的值 1.在datasource.xml...
Spring加载properties配置资源文件的应用
1、加载配置资源文件   class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">            classpath:conf/aa.properties     classpath:conf/bb.properties     classpath:conf/cc.prop
Spring加载Properties配置文件的加密解密处理
需求场景:加密Properties配置文件中的数据库连接字串和用户名、密码 实现思路:重写PropertyPlaceholderConfigurer类中的processProperties方法,在读取配置信息之前实现解密
【spring属性占位符一】加载自定义的properties
在bean定义时设置bean属性的值时,除了设置固定的值,还可以通过EL表达式和占位符来设置,容器在解析bean定义时会对EL表达式和占位符进行解析求值。本篇来学习一下通过占位符定义属性的用法。占位符的取值范围有三个:系统变量(System.getProperty)、坏境变量(System.getEnv)、自定义的Properties文件。1、PropertyPlaceholderConfigur...
Spring 加载并读取 Properties 文件
applicationContext.xml   &amp;lt;context:property-placeholder location=&quot;classpath:sys.properties&quot;/&amp;gt; &amp;lt;bean id=&quot;mongo&quot; class=&quot;com.mongodb.Mongo&quot;&amp;gt; &amp;lt;constructor-arg index=&quot;0&quot; value=&quot;
Spring注解方式加载bean失败
@RunWith(SpringJUnit4ClassRunner.class)rn@ContextConfiguration(locations = "classpath:application-context.xml")rnpublic class SpringJunitTest rn rn @Autowiredrn private TestTbService testTbService;rn rn @Testrn public void test() throws Exceptionrn TestTb tn=new TestTb();rn tn.setName("aaa");rn testTbService.addTestTb(tn);rn rnrnrnrn然后说找不到 testTbService报错如下:rnrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cn.itcast.core.test.SpringJunitTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.itcast.core.service.TestTbService cn.itcast.core.test.SpringJunitTest.testTbService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itcast.core.service.TestTbService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1122)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:379)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)rn at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)rn at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:312)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:211)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:288)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:284)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)rn at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)rn at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:363)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)rnCaused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private cn.itcast.core.service.TestTbService cn.itcast.core.test.SpringJunitTest.testTbService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itcast.core.service.TestTbService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:514)rn at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)rn ... 26 morernCaused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [cn.itcast.core.service.TestTbService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:986)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:856)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:768)rn at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:486)rn ... 28 morern
spring 加载文件失败,java.io.FileNotFoundException
[img=http://img.my.csdn.net/uploads/201211/22/1353554255_8270.jpg][/img]rn这是我的web.xml 截图 rnrn[img=http://img.my.csdn.net/uploads/201211/22/1353554276_8249.jpg][/img]rnrn 这是spring.xml 在src目录下面。rnrn[img=http://img.my.csdn.net/uploads/201211/22/1353554326_2117.jpg][/img]rnrntomcat 报这个错误。
spring学习(4):Spring加载属性(properties)文件
文章目录1.使用注解@PropertySource加载属性文件1.1@PropertySource注解1.2属性文件解析类PropertySourcesPlaceholderconfigurer2.使用XML方式加载属性文件2.1.使用&lt;context:property-placeholder\\&gt;元素加载属性文件2.2.配置PropertyPlaceholderConfigurer的...
IDEA spring的xml配置文件加载不到properties属性问题
Facts里去除spring然后再重新+一下就好了
紧急求助一个关于spring加载properties的问题。
我在spring配置中配置了 PropertyPlaceholderConfigurerrn rn rn rn classpath:xxxx.propertiesrn rn rn rnrn在其他地方使用$xx.xxx来读取properties中的内容。rn而且我需要在网页上修改xxxx.properties的内容,然后保存,并且希望在以后加载bean的时候使用修改后的属性。rnrn现在的问题是,我一修改保存xxxx.properties,spring就去重新加载所有的bean,几百个,搞半天,但是实际上只影响到几个bean而已,请问这个问题怎么解决啊。
读properties class.forname失败
Java 连接Mysql 加载 直接写Class.forName("com.mysql.jdbc.Driver"); 可以成功,但读properties Class.forName(drivers);); drivers = props.getProperty("driver“”( System.out.println(drivers)也可打印com.mysql.jdbc.Driver成功证明取到了 "); 就失败报java.lang.ClassNotFoundException: com.mysql.jdbc.Driver 读url user passw读到可打印 但就是报错都是 具体代码如下ordnprivate void init() n try n // InputStream in = getClass().getResourceAsStream(FILE_PATH_NAME); n InputStream in = DataConnection.class.getClassLoader().getResourceAsStream(FILE_PATH_NAME); n Properties props = new Properties(); n n props.load(in); n in.close(); n drivers = props.getProperty("driver"); n url = props.getProperty("url"); n username = props.getProperty("username"); n password = props.getProperty("password"); n catch (IOException e) n e.printStackTrace(); n n n n n public Connection getConnection() n Connection conn = null; n try n System.out.println(drivers);n Class.forName(drivers);n // System.out.println("com.mysql.jdbc.Driver");n // Class.forName("com.mysql.jdbc.Driver"); n n // conn = DriverManager.getConnection(url, username, password); n conn = DriverManager.getConnection("jdbc:mysql://10.5.0.20/robottest","root", "1234");n catch (SQLException e) n e.printStackTrace(); n catch (ClassNotFoundException e) n e.printStackTrace(); n n return conn; n n 报错n njava.lang.ClassNotFoundException: com.mysql.jdbc.Driver n at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1856)n at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1705)n at java.lang.Class.forName0(Native Method)n at java.lang.Class.forName(Class.java:171)n at dao.DataConnection.getConnection(DataConnection.java:53)n at org.apache.jsp.connTest_jsp._jspService(connTest_jsp.java:120)n at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)n at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)n at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)n at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)n at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)n at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)n at com.atguigu.javaweb.AuthorityFilter.doFilter(AuthorityFilter.java:29)n at com.atguigu.javaweb.HttpFilter.doFilter(HttpFilter.java:59)n at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)n at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)n at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)n at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)n at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)n at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)n at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)n at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)n at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)n at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)n at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)n at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)n at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)n at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)n at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)n at java.lang.Thread.run(Thread.java:662)
properties加载配置文件demo
properties加载配置文件demo package com.properties; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileReader; import java.util.Properties; /** * 读取配置文件 * @author 小明 * *
加载属性文件Properties
package com.sico; import java.io.*; import java.util.Properties; /** ClassLoader用于读取配置文件的信息,配置文件放在classes下 */ @SuppressWarnings(“unused”) public class ConfigUtils { private static Properties prop = ...
Properties配置格式加载
  package com.ls.spring.ioc.dummy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class A { @Autowired p...
设置properties的加载策略
动态加载: 1.需要configuration包: &amp;lt;!-- https://mvnrepository.com/artifact/commons-configuration/commons-configuration --&amp;gt; &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;commo...
加载properties配置文件工具类
import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class ConfigManger { // 加载properties配置文件, 容器 private Properties property = new Properties(); //
java加载.properties配置文件
java加载.properties配置文件           为了让代码比较规范,现在我们的常量都写进配置文件,写进去之后我们通过java怎么来加载这个配置文件呢?主要通过java.util.Properties类来实现。 一、代码结构 二、prop.properties配置文件 socket_port=8989 bootstrap_servers=1
java加载properties工具类
这里分享一个java加载properties的工具类,一般加载完properties文件后,在取值的时候是先取System的Properties然后在取Properties的值,这里还同时支持多个properties文件的加载,废话补多少,代码留下: import java.io.IOException; import java.io.InputStream; import java.util.
JUnit加载properties配置文件
项目测试通常需要在module的test包里用junit写测试样例,但是一般情况下我们会给各种环境使用不同的配置文件,那么在junit下是如何加载properties文件的呢?答案是通过注入类型为org.springframework.beans.factory.config.PropertyPlaceholderConfigurer的bean 1. 在test的resource下新建c
python加载properties配置文件
在python中基本没有遇到这中情况,今天用python跑深度学习的时候,发现有些参数可以放在一个global.properties全局文件中,这样使用的时候更加方便。原理都是加载文件,然后用line方法进行解析
水晶报表加载失败的问题
程序在我本机上,用VS2005直接编译运行,没任何问题。传到服务器上去,打开页面的时候,却提示报表加载失败。rn错误提示:rn“/”应用程序中的服务器错误。rn--------------------------------------------------------------------------------rnrn文件 UNKNOWN.RPT 内出错:rn无法将请求提交给后台处理。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.Runtime.InteropServices.COMException: 文件 UNKNOWN.RPT 内出错:rn无法将请求提交给后台处理。rnrn源错误: rnrnrn行 105: ReportDocument myReport = new ReportDocument();rn行 106: DataOperation myda = new DataOperation();rn行 107: myReport.Load(ApplicationInfo.PhysicalApplicationPath + "/Report/001.rpt");rn行 108: myReport.SetDataSource(myda.GetExeSqlDataSet(sqlstr, "Gysda"));rn行 109: CrystalReportViewer1.ShowFirstPage();rn rnrn源文件: d:\百科公司营运网站\百科公司营运\hf\FundamentalData\MaterialData.aspx.cs 行: 107 rnrn堆栈跟踪: rnrnrn[COMException (0x800002ad): 文件 UNKNOWN.RPT 内出错:rn无法将请求提交给后台处理。]rn CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options) +0rn CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options) +87rn CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +279rnrn[Exception: 加载报表失败。]rn CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened() +340rn CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob) +870rn CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename) +73rn FundamentalData_MaterialData.PrintReport() in d:\百科公司营运网站\百科公司营运\hf\FundamentalData\MaterialData.aspx.cs:107rn FundamentalData_MaterialData.Page_Load(Object sender, EventArgs e) in d:\百科公司营运网站\百科公司营运\hf\FundamentalData\MaterialData.aspx.cs:31rn System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15rn System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34rn System.Web.UI.Control.OnLoad(EventArgs e) +99rn System.Web.UI.Control.LoadRecursive() +47rn System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061rnrn rnrnrn--------------------------------------------------------------------------------rn版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.210 rnrn请问是什么问题呀,在线等,rn rn
加载报表失败问题
我用C#开发一个程序,用到了vs2005内部集成的水晶报表,当我打包成安装程序时,水晶报表打印块出现错了.请问我该如何部署,才能让水晶报表运行正常呢? rn谢谢! rnrnrn错误如下: rn有关调用实时(JIT)调试而不是此对话框的详细信息,rn请参见此消息的结尾。rnrn************** 异常文本 **************rnSystem.Exception: 加载报表失败。 ---> System.Runtime.InteropServices.COMException (0x80004005): 系统找不到指定的路径。 在 CrystalDecisions.ReportAppServer.ClientDoc.ReportClientDocumentClass.Open(Object& DocumentPath, Int32 Options)rn 在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Open(Object& DocumentPath, Int32 Options)rn 在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()rn --- 内部异常堆栈跟踪的结尾 ---rn 在 CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.EnsureDocumentIsOpened()rn 在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename, OpenReportMethod openMethod, Int16 parentJob)rn 在 CrystalDecisions.CrystalReports.Engine.ReportDocument.Load(String filename)rn 在 KuCunGuanLi.CangKu.frmYearReport.CrystalReports(String crystalreportname) 位置 G:\work\进销存\仓库管理1208\仓库管理\KuCunGuanLi\CangKu\frmYearReport.cs:行号 143rn 在 KuCunGuanLi.CangKu.frmYearReport.frmYearReport_Load(Object sender, EventArgs e) 位置 G:\work\进销存\仓库管理1208\仓库管理\KuCunGuanLi\CangKu\frmYearReport.cs:行号 80rn 在 System.Windows.Forms.Form.OnLoad(EventArgs e)rn 在 System.Windows.Forms.Form.OnCreateControl()rn 在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)rn 在 System.Windows.Forms.Control.CreateControl()rn 在 System.Windows.Forms.Control.WmShowWindow(Message& m)rn 在 System.Windows.Forms.Control.WndProc(Message& m)rn 在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)rn 在 System.Windows.Forms.ContainerControl.WndProc(Message& m)rn 在 System.Windows.Forms.Form.WmShowWindow(Message& m)rn 在 System.Windows.Forms.Form.WndProc(Message& m)rn 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)rn 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)rn 在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)rnrnrn************** 已加载的程序集 **************rnmscorlibrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dllrn----------------------------------------rnKuCunGuanLirn 程序集版本: 1.3.1.0rn Win32 版本: 1.3.1.0rn 基本代码: file:///G:/work/进销存/仓库管理1208/仓库管理/KuCunGuanLi/bin/Debug/KuCunGuanLi.exern----------------------------------------rnSystemrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dllrn----------------------------------------rnSystem.Windows.Formsrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dllrn----------------------------------------rnSystem.Drawingrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dllrn----------------------------------------rnSystem.Configurationrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dllrn----------------------------------------rnSystem.Xmlrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dllrn----------------------------------------rnSystem.Datarn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dllrn----------------------------------------rnSystem.Transactionsrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dllrn----------------------------------------rnSystem.EnterpriseServicesrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dllrn----------------------------------------rnmscorlib.resourcesrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dllrn----------------------------------------rnSystem.Windows.Forms.resourcesrn 程序集版本: 2.0.0.0rn Win32 版本: 2.0.50727.42 (RTM.050727-4200)rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms.resources/2.0.0.0_zh-CHS_b77a5c561934e089/System.Windows.Forms.resources.dllrn----------------------------------------rnCrystalDecisions.Windows.Formsrn 程序集版本: 10.2.3600.0rn Win32 版本: 10.2.51014.0rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Windows.Forms/10.2.3600.0__692fbea5521e1304/CrystalDecisions.Windows.Forms.dllrn----------------------------------------rnCrystalDecisions.Sharedrn 程序集版本: 10.2.3600.0rn Win32 版本: 10.2.51014.0rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.Shared/10.2.3600.0__692fbea5521e1304/CrystalDecisions.Shared.dllrn----------------------------------------rnCrystalDecisions.CrystalReports.Engine.resourcesrn 程序集版本: 10.2.3600.0rn Win32 版本: 10.2.51014.0rn 基本代码: file:///F:/WINDOWS/assembly/GAC_MSIL/CrystalDecisions.CrystalReports.Engine.resources/10.2.3600.0_zh-CHS_692fbea5521e1304/CrystalDecisions.CrystalReports.Engine.resources.dllrn----------------------------------------rnrn************** JIT 调试 **************rn要启用实时(JIT)调试,rn该应用程序或计算机的 .config 文件(machine.config)的 system.windows.forms 节中必须设置rnjitDebugging 值。rn编译应用程序时还必须启用rn调试。rnrn例如: rnrnrn rnrnrn启用 JIT 调试后,任何无法处理的异常rn都将被发送到在此计算机上注册的 JIT 调试器,rn而不是由此对话框处理。rnrn----------------------------------rn说明:报表的路经是没有问题的。rnrn
水晶报表的加载失败问题
我在一个Combo控件中设置了商品列表和用户列表并建立了相应的报表文件,rnrnprivate void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)rnrn  int selectedindex=this.comboBox1.SelectedIndex;rn  switch(selectedindex)rn   rn case 1: this.crystalReportViewer1.ReportSource=Application.StartupPath+"\\商品列表.rpt";rn break;rn case 2:rn this.crystalReportViewer1.ReportSource=Application.StartupPath+"\\用户列表.rpt";rn break;rn case 0:rn return;rn   rnrn===================rn在运行的时候就出现加载报表失败啊!rn帮帮忙,看看会是什么原因!
swap加载失败问题
edhat linux9.0安装之后起动,swap linux9.0加载失败,提示 activation swap parttions [fail],但是能够进入系统,只是运行程序特慢,大家说怎么回事?
spring中properties加密
使用spring对properties加密.
spring Properties配置文件的读取
1.PropertiesFactoryBean的使用 1.1 spring配置加入如下: &lt;bean id="pf" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt; &lt;!--设置properties的路径--&gt; &lt;property name="locations"&...
Spring 使用Properties配置文件
1. jdbc.propertiesdatabase.url=jdbc:mysql://localhost/smaple database.driver=org.gjt.mm.mysql.Driver database.user=root database.password=star1xing 2.conf.xml &amp;lt;?xml version=&quot;1.0&quot; encod...
相关热词 c# login 居中 c# 考试软件 c# 自然语言分析 c# 分段读取文件 c# 泛型反射 c#打断点 c# 时间转多少秒 c# 线程函数加参数 c# modbus 读取 c#查询集合表