@Bean @ConfigurationProperties(prefix = "security.oauth2.client") public BaseClientDetails oauth2ClientDetails() { BaseClientDetails details = new BaseClientDetails(); if (this.client.getClientId() == null) { this.client.setClientId(UUID.randomUUID().toString()); } details.setClientId(this.client.getClientId()); details.setClientSecret(this.client.getClientSecret()); details.setAuthorizedGrantTypes(Arrays.asList("authorization_code", "password", "client_credentials", "implicit", "refresh_token")); details.setAuthorities( AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_USER")); details.setRegisteredRedirectUri(Collections.<String>emptySet()); return details; }
@Bean @ConfigurationProperties(DruidServletProperties.DRUID_SERVLET_PREFIX) public ServletRegistrationBean druidServlet(DruidServletProperties properties) { ServletRegistrationBean reg = new ServletRegistrationBean(); reg.setServlet(new StatViewServlet()); reg.addUrlMappings(properties.getUrlMappings()); if(properties.getAllow() !=null){ reg.addInitParameter("allow", properties.getAllow()); // IP白名单 (没有配置或者为空,则允许所有访问) } if(properties.getDeny() !=null){ reg.addInitParameter("deny", properties.getDeny()); //IP黑名单 (存在共同时,deny优先于allow) } if(properties.getLoginUsername() !=null){ reg.addInitParameter("loginUsername", properties.getLoginUsername()); //用户名 } if(properties.getLoginPassword() !=null){ reg.addInitParameter("loginPassword", properties.getLoginPassword()); // 密码 } if(properties.getResetEnable() !=null){ reg.addInitParameter("resetEnable", properties.getResetEnable().toString());// 禁用HTML页面上的“Reset All”功能 } return reg; }
@Bean("blueKitEditProfilePolicy") @ConditionalOnBean(EditProfilePolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.edit-profile", value = {"name", "redirect-url"}) @ConfigurationProperties("blue-kit.b2c.policy.edit-profile") public EditProfilePolicy blueKitEditProfilePolicy(){ return new EditProfilePolicy(); }
@Bean @ConditionalOnMissingBean(AliveHealthEndpoint.class) @ConfigurationProperties("extended.health.alive") public AliveHealthEndpoint applicationAliveEndpoint() { return new AliveHealthEndpoint("alive", new OrderedHealthAggregator()); }
/** * Get data source. * * @return Data source */ @Primary @Bean @ConfigurationProperties(prefix="spring.datasource") public DataSource getDatasource() { return DataSourceBuilder.create().build(); }
@Bean(name="writeDataSource", destroyMethod = "close", initMethod="init") @Primary @ConfigurationProperties(prefix = "spring.datasource") public DataSource writeDataSource() { logger.info("初始化写入数据源……"); return DataSourceBuilder.create().type(dataSourceType).build(); }
@Bean @ConfigurationProperties(prefix = "spring.redis") public JedisConnectionFactory getConnectionFactory() { JedisConnectionFactory factory = new JedisConnectionFactory(); JedisPoolConfig config = getRedisConfig(); factory.setPoolConfig(config); logger.info("JedisConnectionFactory bean init success."); return factory; }
@Bean @ConfigurationProperties("spring.mvc.viewManager") public ContentNegotiationManager contentNegotiationManager() { // 声明contentNegotiationManagerFactory工厂实例,并根据配置参数填充对象。 ContentNegotiationManagerFactoryBean contentNegotiationManagerFactory = new ContentNegotiationManagerFactoryBean(); // 手动填充mediaTypes参数 Map<String, MediaType> mediaTypes = new HashMap<String, MediaType>(); mediaTypes.put("json", MediaType.APPLICATION_JSON_UTF8); mediaTypes.put("xml", MediaType.APPLICATION_XML); contentNegotiationManagerFactory.addMediaTypes(mediaTypes); // 返回contentNegotiationManager对象 return contentNegotiationManagerFactory.getObject(); }
@Bean("blueKitSignInPolicy") @ConditionalOnBean(SignInPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-in", value = {"name", "redirect-url"}) @ConfigurationProperties("blue-kit.b2c.policy.sign-in") public SignInPolicy blueKitSignInPolicy(){ return new SignInPolicy(); }
@Bean @ConditionalOnMissingBean(DetailHealthEndpoint.class) @ConfigurationProperties("extended.health.detail") public DetailHealthEndpoint detailHealthEndpoint() { return new DetailHealthEndpoint("detail", new OrderedHealthAggregator()); }
@Bean @Primary @ConfigurationProperties(prefix = "spring.datasource") public DataSource dataSource() { ConnectionData conData = getDbUrl(); return DataSourceBuilder .create() .url(conData.getUrl() + "?sslmode=require") .username(conData.getUser()) .password(conData.getPassword()) .driverClassName("org.postgresql.Driver") .build(); }
private Map<String, Object> getConfigurationPropertiesBeans( ApplicationContext context, ConfigurationBeanFactoryMetaData beanFactoryMetaData) { Map<String, Object> beans = new LinkedHashMap<String, Object>(); beans.putAll(context.getBeansWithAnnotation(ConfigurationProperties.class)); if (beanFactoryMetaData != null) { beans.putAll(beanFactoryMetaData .getBeansWithFactoryAnnotation(ConfigurationProperties.class)); } return beans; }
@Primary @Bean(name= "dataSource", destroyMethod= "close", initMethod="init") @ConfigurationProperties(prefix="spring.dataSource") public DataSource dataSource() { logger.debug("Configruing DataSource"); return new DruidDataSource(); }
/** * 主库配置(负责写) * @return */ @Bean(name="masterDataSource") @Primary @ConfigurationProperties(prefix = "spring.datasource") public DataSource writeDataSource() { log.info("-------------------- Master DataSource init ---------------------"); return DataSourceBuilder.create().type(dataSourceType).build(); }
@Bean @ConfigurationProperties(DruidStatProperties.DRUID_STAT_PREFIX) public BeanTypeAutoProxyCreator typeProxyCreator(DruidStatProperties properties){ if (properties.getTargetBeanType() == null){ throw new IllegalStateException(DruidStatProperties.DRUID_STAT_PREFIX+".target-bean-type must not null."); } BeanTypeAutoProxyCreator creator = new BeanTypeAutoProxyCreator(); creator.setTargetBeanType(properties.getTargetBeanType()); creator.setProxyTargetClass(proxyTargetClass); creator.setInterceptorNames(DruidStatProperties.DRUID_STAT_INTERCEPTOR_NAME); return creator; }
@Bean @ConfigurationProperties(prefix="spring.redis") public JedisConnectionFactory getConnectionFactory(){ JedisConnectionFactory factory = new JedisConnectionFactory(); JedisPoolConfig config = getRedisConfig(); factory.setPoolConfig(config); System.out.println("JedisConnectionFactory bean init success."); return factory; }
@Bean @Primary @Qualifier("jpaDataSource") @ConfigurationProperties(prefix = "spring.datasource") public DataSource createJpaDataSource() { return DataSourceBuilder.create().type(dataSourceType).build(); }
@Bean @ConfigurationProperties("calcite.datasource") public DataSource calciteDataSource(@Autowired String inlineModel) { DataSource dataSource = DataSourceBuilder .create() .driverClassName("org.apache.calcite.jdbc.Driver") .url("jdbc:calcite:lex=JAVA;model=inline:" + inlineModel) .build(); log.info("Generated Calcite mode: " + inlineModel); return dataSource; }
/** * */ @Bean @RefreshScope @ConfigurationProperties("zuul") public ZuulProperties zuulProperties() { return new ZuulProperties(); }
@ConfigurationProperties(prefix = "spring.datasource.master") @Bean(name = "masterDataSource") @Primary public DataSource masterDataSource() { DruidDataSource dataSource = new DruidDataSource(); try { dataSource.setFilters("stat,wall,log4j"); } catch (SQLException e) { // } return dataSource; }
@Bean("blueKitChangeEmailPolicy") @ConditionalOnBean(ChangeEmailPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.change-email", value = {"name", "redirect-url", "template-url"}) @ConfigurationProperties("blue-kit.b2c.policy.change-email") public ChangeEmailPolicy blueKitChangeEmailPolicy(){ throw new NotFoundException("'change-email' is not a valid policy (yet) provided by Microsoft's Azure AD B2C. You must manually change the email using the GraphApi instead."); }
@Bean @ConditionalOnProperty(prefix = DRUID_WALL_FILTER_PREFIX, name = "enabled", havingValue = "true") @ConfigurationProperties(DRUID_WALL_FILTER_PREFIX) public WallFilter wallFilter(WallConfig wallConfig) { log.debug("druid wall-filter init..."); WallFilter filter = new WallFilter(); filter.setConfig(wallConfig); return filter; }
@Bean @ConditionalOnProperty(prefix = DRUID_SLF4J_FILTER_PREFIX, name = "enabled", havingValue = "true") @ConfigurationProperties(DRUID_SLF4J_FILTER_PREFIX) public Slf4jLogFilter slf4jLogFilter() { log.debug("druid slf4j-filter init..."); return new Slf4jLogFilter(); }
@Bean("blueKitSignUpPolicy") @ConditionalOnBean(SignUpPolicy.class) @ConditionalOnProperty(prefix = "blue-kit.b2c.policy.sign-up", value = {"name", "redirect-url"}) @ConfigurationProperties("blue-kit.b2c.policy.sign-up") public SignUpPolicy blueKitSignUpPolicy(){ return new SignUpPolicy(); }
@Bean @ConfigurationProperties(DruidFilterProperties.DRUID_FILTER_PREFIX) public FilterRegistrationBean druidFilter(DruidFilterProperties properties) { FilterRegistrationBean registration = new FilterRegistrationBean(); WebStatFilter filter = new WebStatFilter(); registration.setFilter(filter); registration.addUrlPatterns(properties.getUrlPattern()); registration.addInitParameter("exclusions",properties.getExclusions()); registration.addInitParameter("sessionStatMaxCount",properties.getSessionStatMaxCount().toString()); registration.addInitParameter("sessionStatEnable",properties.getSessionStatEnable().toString()); registration.addInitParameter("principalSessionName",properties.getPrincipalSessionName()); registration.addInitParameter("principalCookieName",properties.getPrincipalCookieName()); registration.addInitParameter("profileEnable",properties.getProfileEnable().toString()); return registration; }
/** * DataSource * @return DataSource */ @Bean @Primary @ConfigurationProperties(prefix="datasource.idp") public DataSource dataSource() { EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); return builder.setType(EmbeddedDatabaseType.H2).build(); }
/** * Conditionally constructs a new configuration for {@link StatsdMetricsPlugin} if application doesn't provide its own {@link Bean} of * {@link StatsdMetricsConfig} type. * * @return New configuration. */ @Bean @ConditionalOnMissingBean(StatsdMetricsConfig.class) @ConfigurationProperties(prefix = "hekate.metrics.statsd") public StatsdMetricsConfig statsdMetricsConfig() { return new StatsdMetricsConfig(); }
/** * Constructs a new instance of {@link JdkCodecFactory}. * * @return Codec factory. */ @Bean @Qualifier("default") @ConfigurationProperties(prefix = "hekate.codec.jdk") public JdkCodecFactory<Object> jdkCodecFactory() { return new JdkCodecFactory<>(); }
/** * Constructs a new instance of {@link KryoCodecFactory}. * * @return Codec factory. */ @Bean @Qualifier("default") @ConfigurationProperties(prefix = "hekate.codec.kryo") public KryoCodecFactory<Object> kryoCodecFactory() { return new KryoCodecFactory<>(); }
@Bean @Primary @ConfigurationProperties(prefix = "spring.datasource.dbcp2") public org.apache.commons.dbcp2.BasicDataSource dataSource( @Qualifier("dataSourceProperties") DataSourceProperties properties) { return createDataSource(properties, org.apache.commons.dbcp2.BasicDataSource.class); }
/** * 主库配置(负责写) * @return */ @Bean(name="masterDataSource", destroyMethod = "close", initMethod="init") @Primary @ConfigurationProperties(prefix = "spring.datasource",locations = "classpath:application.properties") public DataSource writeDataSource() { log.info("-------------------- Master DataSource init ---------------------"); return DataSourceBuilder.create().type(dataSourceType).build(); }
/** * Conditionally constructs a new configuration for {@link StaticSeedNodeProvider} if application doesn't provide its own {@link * Bean} of {@link StaticSeedNodeProviderConfig} type. * * @return New configuration. */ @Bean @ConditionalOnMissingBean(StaticSeedNodeProviderConfig.class) @ConfigurationProperties(prefix = "hekate.cluster.seed.static") public StaticSeedNodeProviderConfig staticSeedNodeProviderConfig() { return new StaticSeedNodeProviderConfig(); }
/** * Conditionally constructs the configuration for a default failure detector if application doesn't provide its own {@link Bean} of * {@link FailureDetector} type. * * @return Configuration for {@link DefaultFailureDetector}. */ @Bean @ConfigurationProperties(prefix = "hekate.cluster.health") @ConditionalOnMissingBean({FailureDetector.class, DefaultFailureDetectorConfig.class}) public DefaultFailureDetectorConfig defaultFailureDetectorConfig() { return new DefaultFailureDetectorConfig(); }
/** * Constructs the {@link ClusterServiceFactory}. * * @param failureDetector Failure detector. * * @return Service factory. */ @Bean @ConfigurationProperties(prefix = "hekate.cluster") public ClusterServiceFactory clusterServiceFactory(Optional<FailureDetector> failureDetector) { ClusterServiceFactory factory = new ClusterServiceFactory(); failureDetector.ifPresent(factory::setFailureDetector); listeners.ifPresent(factory::setClusterListeners); splitBrainDetector.ifPresent(factory::setSplitBrainDetector); acceptors.ifPresent(factory::setAcceptors); seedNodeProvider.ifPresent(factory::setSeedNodeProvider); return factory; }
@Bean @ConfigurationProperties(prefix="app.alisms") public AlismsClient alismsClient() { return new AlismsClient(); }
@Bean @ConfigurationProperties(prefix = "tx.redis") public JedisPoolConfig getRedisPoolConfig() { return new JedisPoolConfig(); }
@Bean("commonDruidDataProperties") @ConfigurationProperties(prefix = "spring.datasource.common") public Map<String, String> beautyDruidDataProperties() { return new HashMap<String, String>(); }
@Bean @ConfigurationProperties(prefix = "wechat") public ClientResources wechat() { return new ClientResources(); }
@Bean @ConfigurationProperties(prefix = "spring.datasource5") public DataSourceProperties dataSource5Properties() { return new DataSourceProperties(); }
@Bean @ConfigurationProperties(prefix = "spring.datasource5.hikari") public HikariDataSource dataSource5(@Qualifier("dataSource5Properties") DataSourceProperties properties) { return createDataSource(properties, HikariDataSource.class); }