本文整理汇总了Java中org.springframework.core.env.Environment.getActiveProfiles方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.getActiveProfiles方法的具体用法?Java Environment.getActiveProfiles怎么用?Java Environment.getActiveProfiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.core.env.Environment
的用法示例。
在下文中一共展示了Environment.getActiveProfiles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getActiveProfiles
import org.springframework.core.env.Environment; //导入方法依赖的package包/类
/**
* Get the profiles that are applied else get default profiles.
*
* @param env spring environment
* @return profiles
*/
public static String[] getActiveProfiles(Environment env) {
String[] profiles = env.getActiveProfiles();
if (profiles.length == 0) {
return env.getDefaultProfiles();
}
return profiles;
}
示例2: getActiveProfiles
import org.springframework.core.env.Environment; //导入方法依赖的package包/类
/**
* 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;
}
示例3: getActiveProfile
import org.springframework.core.env.Environment; //导入方法依赖的package包/类
public static String getActiveProfile(Environment environment) {
String[] activeProfiles = environment.getActiveProfiles();
if (activeProfiles == null || activeProfiles.length == 0) {
log.warn(String.format("-D%s=[profile] please set profile name, now default develop profile used", ACTIVE_PROFILES_PROPERTY_NAME));
return DEFAULT_PROFILE;
}
if (activeProfiles.length > 1) {
throw new IllegalStateException(String.format("more than one profile name is set : %s", Arrays.toString(activeProfiles)));
}
return activeProfiles[0];
}
示例4: databaseConfigFactory
import org.springframework.core.env.Environment; //导入方法依赖的package包/类
@Bean(name = "dbProps")
public DaoConfigurationPropertiesFactoryBean databaseConfigFactory(ConfigurationDao configurationDao, Environment environment) throws Exception {
return new DaoConfigurationPropertiesFactoryBean(configurationDao, environment.getActiveProfiles(), "*");
}