本文整理了Java中org.springframework.context.annotation.Profile
类的一些代码示例,展示了Profile
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Profile
类的具体详情如下:
包路径:org.springframework.context.annotation.Profile
类名称:Profile
暂无
代码示例来源:origin: macrozheng/mall
/**
* tomcat相关配置
* Created by macro on 2018/8/7.
*/
@Profile("dev")
@Configuration
public class TomcatConfig {
@Value("${http.port}")
private Integer port;
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http
return tomcat;
}
//配置http
private Connector createStandardConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setPort(port);
return connector;
}
}
代码示例来源:origin: apache/metron
@Configuration
@Profile("!" + TEST_PROFILE)
public class StormConfig {
@Autowired
private Environment environment;
@Bean
public StormCLIWrapper stormCLIClientWrapper() {
if (Arrays.asList(environment.getActiveProfiles()).contains(DOCKER_PROFILE)) {
return new DockerStormCLIWrapper(environment);
} else {
return new StormCLIWrapper();
}
}
}
代码示例来源:origin: rabbitmq/rabbitmq-tutorials
@Profile("receiver")
@Bean
public Tut1Receiver receiver() {
return new Tut1Receiver();
}
代码示例来源:origin: ctripcorp/apollo
@Configuration
@Profile("ctrip")
public static class CtripMQConfiguration {
@Bean
public CtripMQService mqService() {
return new CtripMQService();
}
}
代码示例来源:origin: acenelio/spring-boot-ionic-backend
@Configuration
@Profile("dev")
public class DevConfig {
@Autowired
private DBService dbService;
@Value("${spring.jpa.hibernate.ddl-auto}")
private String strategy;
@Bean
public boolean instantiateDatabase() throws ParseException {
if (!"create".equals(strategy)) {
return false;
}
dbService.instantiateTestDatabase();
return true;
}
@Bean
public EmailService emailService() {
return new SmtpEmailService();
}
}
代码示例来源:origin: jmdhappy/xxpay-master
@Component
@Profile(MqConfig.Impl.ACTIVE_MQ)
public class ActiveMq4PayNotify extends Mq4PayNotify{
@Autowired
private Queue payNotifyQueue;
@Autowired
private JmsTemplate jmsTemplate;
代码示例来源:origin: ctripcorp/apollo
@Component
@Profile("ctrip")
public class BizLoggingCustomizer extends LoggingCustomizer {
private final PortalConfig portalConfig;
public BizLoggingCustomizer(final PortalConfig portalConfig) {
this.portalConfig = portalConfig;
}
@Override
protected String cloggingUrl() {
return portalConfig.cloggingUrl();
}
@Override
protected String cloggingPort() {
return portalConfig.cloggingPort();
}
}
代码示例来源:origin: cloudfoundry-incubator/multiapps-controller
@Inject
@Bean
@Profile("cf")
public UAAClient uaaClient(ApplicationConfiguration configuration) {
if (configuration.shouldSkipSslValidation()) {
SSLUtil.disableSSLValidation();
}
return new UAAClientFactory().createClient(readTokenEndpoint(configuration.getControllerUrl()));
}
代码示例来源:origin: rampatra/jbot
@Component
@Profile("slack")
public class SlackWebhooks {
@Value("${slackIncomingWebhookUrl}")
private String slackIncomingWebhookUrl;
代码示例来源:origin: cloudyrock/mongock
private boolean matchesActiveSpringProfile(AnnotatedElement element) {
if (!element.isAnnotationPresent(Profile.class)) {
return true; // no-profiled changeset always matches
}
List<String> profiles = asList(element.getAnnotation(Profile.class).value());
for (String profile : profiles) {
if (profile != null && profile.length() > 0 && profile.charAt(0) == '!') {
if (!activeProfiles.contains(profile.substring(1))) {
return true;
}
} else if (activeProfiles.contains(profile)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: apache/metron
@Configuration
@Profile(LDAP_PROFILE)
public class LdapConfig {
@Autowired
private Environment environment;
@Bean
public LdapTemplate ldapTemplate() {
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl(environment.getProperty(LDAP_PROVIDER_URL_SPRING_PROPERTY));
contextSource.setUserDn(environment.getProperty(LDAP_PROVIDER_USERDN_SPRING_PROPERTY));
contextSource.setPassword(environment.getProperty(LDAP_PROVIDER_PASSWORD_SPRING_PROPERTY));
contextSource.afterPropertiesSet();
return new LdapTemplate(contextSource);
}
}
代码示例来源:origin: rabbitmq/rabbitmq-tutorials
@Profile("sender")
@Bean
public Tut1Sender sender() {
return new Tut1Sender();
}
代码示例来源:origin: ctripcorp/apollo
/**
* spring.profiles.active = ctrip
*/
@Configuration
@Profile("ctrip")
public static class CtripEmailConfiguration {
@Bean
public EmailService ctripEmailService() {
return new CtripEmailService();
}
@Bean
public CtripEmailRequestBuilder emailRequestBuilder() {
return new CtripEmailRequestBuilder();
}
}
代码示例来源:origin: ICOnator/ICOnator-backend
@Configuration
@Profile("dev")
public class KeyGeneration {
@Autowired
private CSVService csvService;
@Autowired
private KeyPairsRepositoryService keyPairsRepositoryService;
@Value(value = "classpath:publickeys-dev.csv")
private Resource publicAddressFile;
private static final Logger LOG = LoggerFactory.getLogger(KeyGeneration.class);
@PostConstruct
public void generateFreshKeys() throws Exception {
List<KeyPairs> keyPairs = csvService.fromCSV(publicAddressFile.getInputStream());
keyPairs.stream().forEach((keyPair) -> {
keyPairsRepositoryService.addKeyPairsIfNotPresent(keyPair);
});
}
}
代码示例来源:origin: jmdhappy/xxpay-master
@Component
@Profile(MqConfig.Impl.RABBIT_MQ)
public class RabbitMq4PayNotify extends Mq4PayNotify {
@Autowired
private AmqpAdmin amqpAdmin;
@Autowired
private AmqpTemplate rabbitTemplate;
代码示例来源:origin: ctripcorp/apollo
@Component
@Profile("ctrip")
public class BizLoggingCustomizer extends LoggingCustomizer{
private final BizConfig bizConfig;
public BizLoggingCustomizer(final BizConfig bizConfig) {
this.bizConfig = bizConfig;
}
@Override
protected String cloggingUrl() {
return bizConfig.cloggingUrl();
}
@Override
protected String cloggingPort() {
return bizConfig.cloggingPort();
}
}
代码示例来源:origin: mongobee/mongobee
private boolean matchesActiveSpringProfile(AnnotatedElement element) {
if (!ClassUtils.isPresent("org.springframework.context.annotation.Profile", null)) {
return true;
}
if (!element.isAnnotationPresent(Profile.class)) {
return true; // no-profiled changeset always matches
}
List<String> profiles = asList(element.getAnnotation(Profile.class).value());
for (String profile : profiles) {
if (profile != null && profile.length() > 0 && profile.charAt(0) == '!') {
if (!activeProfiles.contains(profile.substring(1))) {
return true;
}
} else if (activeProfiles.contains(profile)) {
return true;
}
}
return false;
}
代码示例来源:origin: apache/metron
@Configuration
@Profile("!" + TEST_PROFILE)
public class HBaseConfig {
@Autowired
private GlobalConfigService globalConfigService;
@Autowired
public HBaseConfig(GlobalConfigService globalConfigService) {
this.globalConfigService = globalConfigService;
}
@Bean()
public UserSettingsClient userSettingsClient() {
UserSettingsClient userSettingsClient = new UserSettingsClient();
userSettingsClient.init(() -> {
try {
return globalConfigService.get();
} catch (RestException e) {
throw new IllegalStateException("Unable to retrieve the global config.", e);
}
}, new HTableProvider());
return userSettingsClient;
}
}
代码示例来源:origin: hazelcast/hazelcast-code-samples
@Configuration
@Profile("dev")
public class HazelcastConfig {
@Value("${hz.ip:localhost}")
private String ip;
@Bean
@Scope(value = "prototype")
public HazelcastInstance hazelcastInstance() {
ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress(ip);
return HazelcastClient.newHazelcastClient(config);
}
}
代码示例来源:origin: rabbitmq/rabbitmq-tutorials
@Profile("sender")
@Bean
public Tut5Sender sender() {
return new Tut5Sender();
}
内容来源于网络,如有侵权,请联系作者删除!