java - multiple properties in spring. property in PropertyPlaceholderConfigurer class -


i'm trying create spring project. goal build project jar , war in future. use abc.properties file in classpath contains "conf.path.dir" property. war , jar projects use configuration different locations. , i'm replace abc.properties @ build time , use configure propertyplaceholderconfigurer bean.

<bean id="first" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"       autowire-candidate="false">     <property name="ignoreunresolvableplaceholders" value="true"/>     <property name="locations">         <list>             <value>classpath:abc.properties</value>         </list>     </property> </bean>  <bean id="second" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer" depends-on="first">     <property name="ignoreunresolvableplaceholders" value="true"/>     <property name="locations">         <list>             <value>classpath:ax/add.properties</value>             <value>${conf.path.dir}/main.properties</value>         </list>     </property> </bean> 

unfortunately parameter cannot determined , got following error:

{2015\04\01 11:11:58} (error) #com.mys.fooservice# service got unexpected error:  org.springframework.beans.factory.beaninitializationexception: not load properties; nested exception java.io.filenotfoundexception: class path resource [${conf.path.dir}/main.properties] cannot opened because not exist     @ org.springframework.beans.factory.config.propertyresourceconfigurer.postprocessbeanfactory(propertyresourceconfigurer.java:87)     @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:694)     @ org.springframework.context.support.abstractapplicationcontext.invokebeanfactorypostprocessors(abstractapplicationcontext.java:669)     @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:461)     @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:139)     @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:83)     @ com.mys.fooservice.start(fooservice.java:149)     @ com.mys.fooservice$1serviceinstancelock.<init>(fooservice.java:12)     @ com.mys.fooservice.main(fooservice.java:137)     @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)     @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:39)     @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:25)     @ java.lang.reflect.method.invoke(method.java:597)     @ com.intellij.rt.execution.application.appmain.main(appmain.java:140) caused by: java.io.filenotfoundexception: class path resource [${conf.path.dir}/main.properties] cannot opened because not exist     @ org.springframework.core.io.classpathresource.getinputstream(classpathresource.java:157)     @ org.springframework.core.io.support.encodedresource.getinputstream(encodedresource.java:143)     @ org.springframework.core.io.support.propertiesloaderutils.fillproperties(propertiesloaderutils.java:98)     @ org.springframework.core.io.support.propertiesloadersupport.loadproperties(propertiesloadersupport.java:175)     @ org.springframework.core.io.support.propertiesloadersupport.mergeproperties(propertiesloadersupport.java:156)     @ org.springframework.beans.factory.config.propertyresourceconfigurer.postprocessbeanfactory(propertyresourceconfigurer.java:78)     ... 13 more 

spring version: 3.2.4 how fix , resolve "conf.path.dir" abc.properties?

try replacing

<value>${conf.path.dir}/main.properties</value> 

with

<value>file:///#{conf.path.dir}/main.properties</value> 

that should solve problem.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -