简体   繁体   English

如何加载外部属性文件并将值加载到另一个属性文件

[英]How to load an external property file and load the values to another properties file

I want load an external property file and set it values to another properties file, that is possible? 我想加载一个外部属性文件并将其值设置为另一个属性文件,这可能吗? eg: 例如:

C:\\properties\\file.properties C:\\ properties \\ file.properties

id=userID id =用户ID

password=pass 密码=通过

./main/resources/application.properties ./main/resources/application.properties

user.id=${id} user.id = $ {id}

user.password=${password} user.password = $ {密码}

I tray run this command, but it isn't working 我执行了以下命令,但无法正常工作

java -jar -Dspring.config.location=C:/properties/file.properties  java-1.0-SNAPSHOT.jar


exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'id' in value "${id}"

You can use @PropertySource annotation from spring boot libraries. 您可以在Spring Boot库中使用@PropertySource批注。 Documentation and examples: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html 文档和示例: https : //docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM