本文整理了Java中org.springframework.core.env.Environment.getDefaultProfiles()
方法的一些代码示例,展示了Environment.getDefaultProfiles()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getDefaultProfiles()
方法的具体详情如下:
包路径:org.springframework.core.env.Environment
类名称:Environment
方法名:getDefaultProfiles
[英]Return the set of profiles to be active by default when no active profiles have been set explicitly.
[中]
代码示例来源:origin: spring-cloud/spring-cloud-config
public ConfigClientProperties(Environment environment) {
String[] profiles = environment.getActiveProfiles();
if (profiles.length == 0) {
profiles = environment.getDefaultProfiles();
}
this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles));
}
代码示例来源:origin: com.minlia.cloud/minlia-cloud-starter
/**
* Get the profiles that are applied else get default profiles.
*/
public static String[] getActiveProfiles(Environment env) {
String[] profiles = env.getActiveProfiles();
if (profiles.length == 0) {
return env.getDefaultProfiles();
}
return profiles;
}
}
代码示例来源:origin: zalando-incubator/catwatch
@PostConstruct
public void postConstruct() {
System.out.println("================== " + DebugBean.class.getName() + "=================================");
System.out.println("active profiles: " + on(",").join(env.getActiveProfiles()));
System.out.println("default profiles: " + on(",").join(env.getDefaultProfiles()));
System.out
.println("spring.database.driverClassName: " + env.getProperty("spring.database.driverClassName"));
System.out.println("spring.jpa.hibernate.ddl-auto: " + env.getProperty("spring.jpa.hibernate.ddl-auto"));
System.out.println("all beans:");
stream(context.getBeanDefinitionNames()).forEach(System.out::println);
System.out.println("================== " + DebugBean.class.getName() + "=================================");
}
代码示例来源:origin: spring-cloud/spring-cloud-gcp
public GcpConfigProperties(Environment environment) {
if (this.profile == null) {
String[] profiles = environment.getActiveProfiles();
if (profiles.length == 0) {
profiles = environment.getDefaultProfiles();
}
if (profiles.length > 0) {
this.profile = profiles[profiles.length - 1];
}
else {
this.profile = "default";
}
}
}
代码示例来源:origin: net.nemerosa.ontrack/ontrack-service
@Autowired
public EnvServiceImpl(VersionInfoConfig version,
OntrackConfigProperties configProperties,
ApplicationContext ctx) {
this.defaultProfiles = StringUtils.join(ctx.getEnvironment().getDefaultProfiles(), ",");
this.profiles = StringUtils.join(ctx.getEnvironment().getActiveProfiles(), ",");
// Version information from the configuration
this.version = version.toInfo();
// JDBC URL
this.jdbcUrl = ctx.getEnvironment().getProperty("spring.datasource.url");
// Home directory
this.home = new File(configProperties.getApplicationWorkingDir());
}
代码示例来源:origin: org.springframework.cloud/spring-cloud-config-client
public ConfigClientProperties(Environment environment) {
String[] profiles = environment.getActiveProfiles();
if (profiles.length == 0) {
profiles = environment.getDefaultProfiles();
}
this.setProfile(StringUtils.arrayToCommaDelimitedString(profiles));
}
代码示例来源:origin: liuyuyu/dictator
/**
* 能够获取原来配置,可以用的初始化方式
*/
public static void init(@NonNull Environment environment) {
//取Spring的profile作为环境区分的标识
List<String> activeProfileList = Arrays.stream(environment.getActiveProfiles())
.collect(Collectors.toList());
String mainProfile = activeProfileList.stream()
.findFirst()
.orElse(environment.getDefaultProfiles()[0]);
DictatorClientProperties dictatorClientProperties = DictatorClientProperties.of();
dictatorClientProperties.setProfile(mainProfile);
dictatorClientProperties.setServerUrl(environment.getProperty("dictator.serverUrl"));
dictatorClientProperties.setAppCode(environment.getProperty("dictator.appCode"));
dictatorClientProperties.setProfile(mainProfile);
// 打印参数
dictatorClientProperties.printCurrent();
//验证参数
dictatorClientProperties.verify();
DICTATOR_CLIENT = DictatorClient.of(dictatorClientProperties);
DictatorPropertyManager.refreshCache();
}
内容来源于网络,如有侵权,请联系作者删除!