【发布时间】:2018-07-05 10:56:02
【问题描述】:
我正在尝试确定应用程序所在的环境,但使用 Weblogic 在启动时通过此行设置的环境变量:
-Denvironment=DEV
我在下面有一个配置类:
package ie.gov.agriculture.cds;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@PropertySource("classpath:application.properties")
public class AppConfig {
@Value("${environment}")
private String env;
@Bean
public static PropertySourcesPlaceholderConfigurer propertyConfigInDev() {
return new PropertySourcesPlaceholderConfigurer();
}
}
在 application.properties 中,如果我定义属性“环境”,那么它似乎可以工作,但这不是我想要实现的。 看来我需要用指向 weblogic 服务器的东西替换 PropertySource 注释值?
任何帮助将不胜感激!
【问题讨论】:
标签: java spring-boot weblogic environment spring-java-config