Java Code Examples for org.springframework.boot.context.properties.ConfigurationProperties

The following are top voted examples for showing how to use org.springframework.boot.context.properties.ConfigurationProperties. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: spring-security-oauth2-boot   File: OAuth2AuthorizationServerConfiguration.java   View source code 6 votes vote down vote up
@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;
}
 
Example 2
Project: druid-boot-starter   File: DruidServletAutoConfiguration.java   View source code 6 votes vote down vote up
@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;
}
 
Example 3
Project: xitikit-blue   File: B2CPolicyAutoConfiguration.java   View source code 5 votes vote down vote up
@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();
}
 
Example 4
Project: extended-actuator-health-endpoints   File: ExtendedHealthEndpointAutoConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(AliveHealthEndpoint.class)
@ConfigurationProperties("extended.health.alive")
public AliveHealthEndpoint applicationAliveEndpoint() {

    return new AliveHealthEndpoint("alive", new OrderedHealthAggregator());
}
 
Example 5
Project: REST-Web-Services   File: WebDatasourceConfig.java   View source code 5 votes vote down vote up
/**
 * Get data source.
 *
 * @return Data source
 */
@Primary
@Bean
@ConfigurationProperties(prefix="spring.datasource")
public DataSource getDatasource() {
    return DataSourceBuilder.create().build();
}
 
Example 6
Project: read-write-sever   File: DatabaseConfig.java   View source code 5 votes vote down vote up
@Bean(name="writeDataSource", destroyMethod = "close", initMethod="init")
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource writeDataSource() {
    logger.info("初始化写入数据源……");
    return DataSourceBuilder.create().type(dataSourceType).build();
}
 
Example 7
Project: sds   File: RedisConfig.java   View source code 5 votes vote down vote up
@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;
}
 
Example 8
Project: jeeWe   File: MvcViewConfiguration.java   View source code 5 votes vote down vote up
@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();
}
 
Example 9
Project: xitikit-blue   File: B2CPolicyAutoConfiguration.java   View source code 5 votes vote down vote up
@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();
}
 
Example 10
Project: extended-actuator-health-endpoints   File: ExtendedHealthEndpointAutoConfiguration.java   View source code 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(DetailHealthEndpoint.class)
@ConfigurationProperties("extended.health.detail")
public DetailHealthEndpoint detailHealthEndpoint() {

    return new DetailHealthEndpoint("detail", new OrderedHealthAggregator());
}
 
Example 11
Project: participationSystem3a   File: DataSourceBean.java   View source code 5 votes vote down vote up
@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();
}
 
Example 12
Project: ARCLib   File: Gatherer.java   View source code 5 votes vote down vote up
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;
}
 
Example 13
Project: lemon-dubbo-message   File: DatabaseConfiguration.java   View source code 5 votes vote down vote up
@Primary
@Bean(name= "dataSource", destroyMethod= "close", initMethod="init")
   @ConfigurationProperties(prefix="spring.dataSource")
   public DataSource dataSource() {
	logger.debug("Configruing DataSource");
	return new DruidDataSource();
   }
 
Example 14
Project: MI-S   File: DataBaseConfiguration.java   View source code 5 votes vote down vote up
/**
 * 主库配置(负责写)
 * @return
 */
@Bean(name="masterDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource writeDataSource() {
    log.info("-------------------- Master DataSource init ---------------------");
    return DataSourceBuilder.create().type(dataSourceType).build();
}
 
Example 15
Project: druid-boot-starter   File: DruidTypeAopAutoConfiguration.java   View source code 5 votes vote down vote up
@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;
}
 
Example 16
Project: xcx-specialty   File: RedisConfiguration.java   View source code 5 votes vote down vote up
@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;  
}
 
Example 17
Project: data-migration   File: DataSourceConfiguration.java   View source code 5 votes vote down vote up
@Bean
@Primary
@Qualifier("jpaDataSource")
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource createJpaDataSource() {
    return DataSourceBuilder.create().type(dataSourceType).build();
}
 
Example 18
Project: calcite-sql-rewriter   File: SqlRewriterConfiguration.java   View source code 5 votes vote down vote up
@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;
}
 
Example 19
Project: learn-spring-cloud   File: StartGatewayDynamicServer.java   View source code 5 votes vote down vote up
/**
 *
 */
@Bean
@RefreshScope
@ConfigurationProperties("zuul")
public ZuulProperties zuulProperties() {
    return new ZuulProperties();
}
 
Example 20
Project: SpringBoot-Study   File: MasterDruidDataSourceConfig.java   View source code 5 votes vote down vote up
@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;
}
 
Example 21
Project: xitikit-blue   File: B2CPolicyAutoConfiguration.java   View source code 5 votes vote down vote up
@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.");
}
 
Example 22
Project: druid-spring-boot   File: DruidAutoConfiguration.java   View source code 5 votes vote down vote up
@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;
}
 
Example 23
Project: druid-spring-boot   File: DruidAutoConfiguration.java   View source code 5 votes vote down vote up
@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();
}
 
Example 24
Project: xitikit-blue   File: B2CPolicyAutoConfiguration.java   View source code 5 votes vote down vote up
@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();
}
 
Example 25
Project: druid-boot-starter   File: DruidFilterAutoConfiguration.java   View source code 5 votes vote down vote up
@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;
}
 
Example 26
Project: Your-Microservice   File: YourMicroserviceEnvironmentConfiguration.java   View source code 5 votes vote down vote up
/**
 * DataSource
 * @return DataSource
 */
@Bean
@Primary
@ConfigurationProperties(prefix="datasource.idp")
public DataSource dataSource() {
    EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
    return builder.setType(EmbeddedDatabaseType.H2).build();
}
 
Example 27
Project: hekate   File: StatsdMetricsPluginConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 28
Project: hekate   File: HekateJdkCodecConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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<>();
}
 
Example 29
Project: hekate   File: HekateKryoCodecConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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<>();
}
 
Example 30
Project: spring-boot-multidatasource   File: DataSourceConfiguration.java   View source code 5 votes vote down vote up
@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);
}
 
Example 31
Project: MI-S   File: DataBaseConfiguration.java   View source code 5 votes vote down vote up
/**
 * 主库配置(负责写)
 * @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();
}
 
Example 32
Project: hekate   File: HekateStaticSeedNodeProviderConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 33
Project: hekate   File: HekateClusterServiceConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 34
Project: hekate   File: HekateClusterServiceConfigurer.java   View source code 5 votes vote down vote up
/**
 * 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;
}
 
Example 35
Project: lemon-dubbo-message   File: SpringConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix="app.alisms")
public AlismsClient alismsClient() {
	return new AlismsClient();
}
 
Example 36
Project: happylifeplat-transaction   File: TxManagerConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "tx.redis")
public JedisPoolConfig getRedisPoolConfig() {
    return new JedisPoolConfig();
}
 
Example 37
Project: spring-cloud-samples   File: DataSourceConfig.java   View source code 4 votes vote down vote up
@Bean("commonDruidDataProperties")
@ConfigurationProperties(prefix = "spring.datasource.common")
public Map<String, String> beautyDruidDataProperties() {
	return new HashMap<String, String>();
}
 
Example 38
Project: springboot-security-wechat   File: SecurityConfig.java   View source code 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "wechat")
public ClientResources wechat() {
    return new ClientResources();
}
 
Example 39
Project: spring-boot-multidatasource   File: DataSourceConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "spring.datasource5")
public DataSourceProperties dataSource5Properties() {
	return new DataSourceProperties();
}
 
Example 40
Project: spring-boot-multidatasource   File: DataSourceConfiguration.java   View source code 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "spring.datasource5.hikari")
public HikariDataSource dataSource5(@Qualifier("dataSource5Properties") DataSourceProperties properties) {
	return createDataSource(properties, HikariDataSource.class);
}