Try using placeholders to hold the System property key: ${user.home}
. Also you have duplicated the database.properties
in the System property and the config file.
Access class path property AND user-defined property file with Spring Context?
-
01-06-2023 - |
Pregunta
I have tried to access class path property & user-defined path property file as below:
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>Common.properties</value>
<value>user.home:/database.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="ignoreResourceNotFound" value="false"/>
</bean>
Here Common.properties
path is working but user.home:/database.properties
path is not working. It is showing the error:
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [user.home:/database.properties] cannot be opened because it does not exist
(MSC service thread 1-6) at org.springframework.beans.factory.config.PropertyResourceConfigurer.postProcessBeanFactory(PropertyResourceConfigurer.java:87)
Am using jBoss 7 and I have changed standalone.bat to include the below path:
set JAVA_OPTS=-Duser.home=file:%JBOSS_CONFIG_DIR%/database.properties
Is this correct?? If any other way to access custom property path please let me know.
No hay solución correcta
Otros consejos
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow