【发布时间】:2017-10-24 14:28:51
【问题描述】:
我有 2 个 URL,其中 1 个专用于 Dev,另一个专用于 Prod。 我也在使用 Spring 分析,其中我有单独的文件用于 dev 和 prod application-dev.properties 和 application-prod.properties 以及我的 开发环境的 appication.properties 文件看起来像这样
spring.profiles.active=dev
现在在我的 java 代码中,我想要一个属性,该属性将根据我使用的弹簧配置文件绑定到适当的值。我该怎么做。
当前的 Java 类:-
//DEV
private static final String WIND_RESOURCE_EXTRACTOR_URL = "https://localhost:9090/dev";
//FOR PROD
//private static final String WIND_RESOURCE_EXTRACTOR_URL = "https://localhost:9090/prod";
所以我想在我的 application-dev.properties 或 application-prod.properties 文件中提及这个属性,我的 java 类应该根据当前的 spring 配置文件选择正确的值。
【问题讨论】:
标签: java spring spring-profiles