【发布时间】:2019-05-12 18:35:23
【问题描述】:
行家:
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<active.spring.profile>local</active.spring.profile>
</properties>
</profile>
</profiles>
application.properties:
spring.profiles.active=@active.spring.profile@
spring.config.additional-location=classpath:/profile/application-${spring.profiles.active}.properties
在此之后,我无法从包含 test.prop=123 的 src/main/resources/application-local.properties 中获取价值
@Service
public class TestProps {
@Value("${test.prop}")
String testProp;
@PostConstruct
void run() {
System.out.println(testProp);
}
}
错在哪里?或者这是一个错误?
【问题讨论】:
-
(1) 您的链接已损坏,(2) 正是为了避免将来出现此类风险,我们要求问题具有最小但完整的代码示例,这将使我们能够在问题本身中重现问题而不是链接。请参阅minimal reproducible example。
-
网址是固定的
标签: java maven spring-boot