【发布时间】:2016-04-29 15:30:43
【问题描述】:
如何在 Spring Boot 中从单独的文件中读取属性?
我正在尝试他在这里做什么..http://www.mkyong.com/spring/spring-propertysources-example/
但它不读取文件?
假设您在资源文件夹中有一个 file.properties。
你应该输入:
spring.configuration.location: classpath:file.properties
在 application.properties 中指向文件。
然后在你的 MyConfig 类中
@Service
public class MyConfig{
@Value("${prop.one}")
private String propOne;
这不应该吗?我做错了什么
在某处有这样做的简单示例吗?
谢谢!
【问题讨论】: