I have a text file which contains data. I want to set this data to a String instance variable.
I know I can do it using Java I/O, read the file and set it's content to String variable.
But is there a simplistic way to initialize the String using Spring configuration file?
Try using properties file with this xml tags:
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:YourFile.properties" />
</bean>
And use the values as ${your_key}
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.