accessing property file from outside war file then am getting error message its absolute path then working fine .Please help
<util:properties id="configs" location="${ext.prop.file}/config.properties" /> --Not working
ext.prop.file = " c:/test
<util:properties id="configs" location="file:/c:/test/config.properties" /> -- Working fine
You can do this by simply adding it to the context
of the application at the time of context loading.
<context:property-placeholder location="${propfile}"/>
Above config will load the property file onto the context using the variable propFile
. This variable is declared at runtime, as below.
-DpropFile="file:/path/to/file.properties"
Thereafter, you can use @Values
annotation in your class to access properties from this file.
@Values("${someVal}")
private String someVal;
Above statement is trying to access property with key as someVal
in property file and assign it to String someVal
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.