如何检查 JHipster 环境
How to check JHipster environment
谁能告诉我这是否是使用 JHipster 时检查当前环境的正确方法?
public DwollaService(ApplicationProperties applicationProperties, Environment env) throws Exception {
this.dwolla = applicationProperties.dwolla;
this.env = env;
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
Boolean isProd = activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
this.dwollaClient = new Dwolla(
this.dwolla.getKey(),
this.dwolla.getSecret(),
(isProd) ? DwollaEnvironment.PRODUCTION : DwollaEnvironment.SANDBOX
);
}
您的代码有效,但以下是识别产品环境的更好方法(事实上 spring 已弃用 checking active profiles based on strings)。
isProd = env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_PRODUCTION));
谁能告诉我这是否是使用 JHipster 时检查当前环境的正确方法?
public DwollaService(ApplicationProperties applicationProperties, Environment env) throws Exception {
this.dwolla = applicationProperties.dwolla;
this.env = env;
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
Boolean isProd = activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION);
this.dwollaClient = new Dwolla(
this.dwolla.getKey(),
this.dwolla.getSecret(),
(isProd) ? DwollaEnvironment.PRODUCTION : DwollaEnvironment.SANDBOX
);
}
您的代码有效,但以下是识别产品环境的更好方法(事实上 spring 已弃用 checking active profiles based on strings)。
isProd = env.acceptsProfiles(Profiles.of(JHipsterConstants.SPRING_PROFILE_PRODUCTION));