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

The following examples show how to use org.springframework.boot.context.properties.ConfigurationProperties. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Bean
@ProcessAsyncHistory
@ConfigurationProperties(prefix = "flowable.process.async-history.executor")
@ConditionalOnMissingBean(name = "asyncHistoryExecutor")
@ConditionalOnProperty(prefix = "flowable.process", name = "async-history.enable")
public SpringAsyncHistoryExecutor asyncHistoryExecutor(
    ObjectProvider<TaskExecutor> taskExecutor,
    @Process ObjectProvider<TaskExecutor> processTaskExecutor,
    ObjectProvider<SpringRejectedJobsHandler> rejectedJobsHandler,
    @Process ObjectProvider<SpringRejectedJobsHandler> processRejectedJobsHandler
) {
    return new SpringAsyncHistoryExecutor(
        getIfAvailable(processTaskExecutor, taskExecutor),
        getIfAvailable(processRejectedJobsHandler, rejectedJobsHandler)
    );
}
 
Example 2
@Bean(name = "myBatisDataSource")
    @Primary
    @ConfigurationProperties(prefix = "data-source.single-db")
    public DataSource userDataSource() throws IOException, SQLException {
        if(!useMasterSlaveDataSource) {
            logger.info("-------------------- singleDB DataSource init ---------------------");
            return DataSourceBuilder.create().build();
        }else {
            logger.info("-------------------- masterSlave DataSource init ---------------------");
//            DataSource dataSource = YamlMasterSlaveDataSourceFactory.createDataSource(new File(
//                    DataSourceConfiguration.class.getResource("/META-INF/yamlMasterSlave.yaml").getFile()));
//            return dataSource;
            return null == masterSlaveProperties.getMasterDataSourceName()
                    ? ShardingDataSourceFactory.createDataSource(dataSourceMap, shardingProperties.getShardingRuleConfiguration(), configMapProperties.getConfigMap(), propMapProperties.getProps())
                    : MasterSlaveDataSourceFactory.createDataSource(
                    dataSourceMap, masterSlaveProperties.getMasterSlaveRuleConfiguration(), configMapProperties.getConfigMap(), propMapProperties.getProps());
        }
    }
 
Example 3
Source Project: supplierShop   Source File: DruidConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
    DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
    return druidProperties.dataSource(dataSource);
}
 
Example 4
@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 5
@Bean
@ConditionalOnMissingBean
@ConfigurationProperties("spring.boot.admin.notify.letschat")
public LetsChatNotifier letsChatNotifier(InstanceRepository repository,
		NotifierProxyProperties proxyProperties) {
	return new LetsChatNotifier(repository, createNotifierRestTemplate(proxyProperties));
}
 
Example 6
@Bean(BEAN_DEFAULT_EMBEDDED_WEBAPPS_PROPERTIES)
@ConfigurationProperties(prefix = KEY_EMBEDDED_WEBAPP_BASE)
@ConditionalOnProperty(value = KEY_EMBEDDED_WEBAPP_BASE + ".enabled", matchIfMissing = false)
public GenericEmbeddedWebappsProperties defaultEmbeddedWebappsEndpointProperties() {
	return new GenericEmbeddedWebappsProperties() {
	};
}
 
Example 7
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource dataSource() {
    // 配置数据源(注意,我使用的是 HikariCP 连接池),以上注解是指定数据源,否则会有冲突
    return DataSourceBuilder.create().build();
}
 
Example 8
Source Project: hono   Source File: HotrodCacheConfig.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Gets properties for configuring the service's common cache aspects.
 *
 * @return The properties.
 */
@Bean
@ConfigurationProperties(prefix = "hono.device-connection.common")
@ConditionalOnProperty(prefix = "hono.device-connection", name = "server-list")
public CommonCacheConfig commonCacheConfig() {
    return new CommonCacheConfig();
}
 
Example 9
@Bean
@ConfigurationProperties(prefix = "hsweb.authorize")
public AopAuthorizingController aopAuthorizingController(AuthorizingHandler authorizingHandler,
                                                         AopMethodAuthorizeDefinitionParser aopMethodAuthorizeDefinitionParser) {

    return  new AopAuthorizingController(authorizingHandler, aopMethodAuthorizeDefinitionParser);
}
 
Example 10
Source Project: Kafdrop   Source File: CuratorConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Primary
@Bean
@ConfigurationProperties(prefix = "kafka.zookeeper")
public ZookeeperProperties zookeeperProperties()
{
   return new ZookeeperProperties();
}
 
Example 11
Source Project: spring-boot-demo   Source File: PrimaryJpaConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 扫描spring.jpa.primary开头的配置信息
 *
 * @return jpa配置信息
 */
@Primary
@Bean(name = "primaryJpaProperties")
@ConfigurationProperties(prefix = "spring.jpa.primary")
public JpaProperties jpaProperties() {
    return new JpaProperties();
}
 
Example 12
@Override
public void postProcessBeforeDestruction(Object bean, String name) throws BeansException {
    if (environment == null) {
        return;
    }

    Object target = bean;
    if (AopUtils.isAopProxy(bean)) {
        target = ProxyUtils.getTargetObject(target);
    }

    if (AnnotationUtils.findAnnotation(target.getClass(), ConfigurationProperties.class) == null) {
        return;
    }

    try {
        target.getClass().getConstructor();
    } catch (NoSuchMethodException e) {
        logger.debug("can not found default constructor, skip it");
        return;
    }

    try {
        ConfigurationProperties annotation = AnnotationUtils.findAnnotation(
                target.getClass(), ConfigurationProperties.class);
        String prefix = annotation.prefix();
        Object result = Binder.get(environment).bind(prefix, (Class) target.getClass()).orElseCreate(target.getClass());
        BeanUtils.copyProperties(result, target);
    } catch (Throwable t) {
        logger.warn("error while process destruction bean with name: {}", name, t);
    }
}
 
Example 13
Source Project: SuperBoot   Source File: DruidDataSourceConfig.java    License: MIT License 5 votes vote down vote up
/**
 * DataSource 读数据源配置
 *
 * @return
 */
@ConfigurationProperties(prefix = "spring.datasource.readDruidDataSource")
@Qualifier("readDruidDataSource")
@Bean(name = "readDruidDataSource")
public DruidDataSource readDruidDataSource() {
    return DruidDataSourceBuilder.create().build(env, "spring.datasource.readDruidDataSource.");
}
 
Example 14
Source Project: SpringBootUnity   Source File: MultipleSourceMain.java    License: MIT License 5 votes vote down vote up
/**
 * 第二个数据源
 * @return 数据源实例
 */
@Bean(name = "secondaryDataSource")
@Qualifier("secondaryDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource.secondary")
public DataSource secondaryDataSource() {
    return DataSourceBuilder.create().build();
}
 
Example 15
Source Project: genie   Source File: AwsAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Provide a configuration properties bean for Spring Cloud resource loader properties if for whatever reason
 * the {@link ContextResourceLoaderAutoConfiguration} isn't applied by the agent app.
 *
 * @return A {@link AwsS3ResourceLoaderProperties} instance with the bindings from cloud.aws.loader values
 */
@Bean
@ConditionalOnMissingBean(AwsS3ResourceLoaderProperties.class)
@ConfigurationProperties(ContextResourceLoaderAutoConfiguration.AWS_LOADER_PROPERTY_PREFIX)
public AwsS3ResourceLoaderProperties awsS3ResourceLoaderProperties() {
    return new AwsS3ResourceLoaderProperties();
}
 
Example 16
Source Project: mini-platform   Source File: MyBatisOAuthConfig.java    License: MIT License 5 votes vote down vote up
@Primary
@RefreshScope
@Bean(name = "dataSourceOAuth")
@ConfigurationProperties(prefix = "spring.datasource.oauth")
public DataSource dataSourceOAuth() {
    return DataSourceBuilder.create().build();
}
 
Example 17
/**
 * 数据源信息
 *
 * @return
 */
@Primary
@Bean(name = DATABASE_PREFIX + "DruidDataSource")
@ConfigurationProperties(prefix = "spring.datasource.druid")
public DataSource druidDataSource() {
    return DruidDataSourceBuilder.create().build();
}
 
Example 18
Source Project: RuoYi-Vue   Source File: DruidConfig.java    License: MIT License 5 votes vote down vote up
@Bean
@ConfigurationProperties("spring.datasource.druid.slave")
@ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
public DataSource slaveDataSource(DruidProperties druidProperties)
{
    DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
    return druidProperties.dataSource(dataSource);
}
 
Example 19
@Bean
@ConfigurationProperties("spring.datasource")
@LiquibaseDataSource
public DataSource dataSource(DataSourceProperties properties) {
	return new SimpleDriverDataSource(new org.postgresql.Driver(), properties.getUrl(),
			properties.getDataUsername(), properties.getDataPassword());
}
 
Example 20
Source Project: hono   Source File: AbstractAdapterConfig.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Exposes configuration properties for ResourceLimitChecks as a Spring bean.
 *
 * @return The properties.
 */
@Bean
@ConfigurationProperties(prefix = "hono.resource-limits.prometheus-based")
@ConditionalOnClass(name = "io.micrometer.prometheus.PrometheusMeterRegistry")
@ConditionalOnProperty(name = "hono.resource-limits.prometheus-based.host")
public PrometheusBasedResourceLimitChecksConfig resourceLimitChecksConfig() {
    return new PrometheusBasedResourceLimitChecksConfig();
}
 
Example 21
@Bean(name = { "dataSource", "dataSource1" })
@ConfigurationProperties(prefix = "spring.multitenancy.datasource1")
public DataSource dataSource1() {
	DataSourceBuilder factory = DataSourceBuilder
			.create(this.multitenancyProperties.getDatasource1().getClassLoader())
			.driverClassName(this.multitenancyProperties.getDatasource1().getDriverClassName())
			.username(this.multitenancyProperties.getDatasource1().getUsername())
			.password(this.multitenancyProperties.getDatasource1().getPassword())
			.url(this.multitenancyProperties.getDatasource1().getUrl());
	return factory.build();
}
 
Example 22
@Bean("emxDigitalConfigurationProperties")
@ConfigurationProperties("adapters.emxdigital")
BidderConfigurationProperties configurationProperties() {
    return new BidderConfigurationProperties();
}
 
Example 23
Source Project: spring-boot-samples   Source File: SeataConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource druidDataSource() {
    HikariDataSource hikariDataSource = new HikariDataSource();
    return hikariDataSource;
}
 
Example 24
Source Project: enmasse   Source File: ApplicationConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Gets general properties for configuring the Device Registry Spring Boot application.
 *
 * @return The properties.
 */
@Bean
@ConfigurationProperties(ConfigBase.CONFIG_BASE + ".app")
public ApplicationConfigProperties applicationConfigProperties(){
    return new ApplicationConfigProperties();
}
 
Example 25
Source Project: flow-platform-x   Source File: ConfigProperties.java    License: Apache License 2.0 4 votes vote down vote up
@Bean("pluginProperties")
@ConfigurationProperties(prefix = "app.plugin")
public Plugin plugin() {
    return new Plugin();
}
 
Example 26
@Bean
@ConfigurationProperties(prefix = "hsweb.web.upload")
public FdfsFileService fdfsFileService() {
    return new FdfsFileService();
}
 
Example 27
@Bean
@ConfigurationProperties(prefix = CossAccessProperties.KEY_ACCESS_PREFIX)
public CossAccessProperties cossAccessProperties() {
	return new CossAccessProperties();
}
 
Example 28
@Bean
@ConfigurationProperties
public ValidatedClass nonValidatedClass() {
	return new ValidatedClass();
}
 
Example 29
Source Project: hono   Source File: ApplicationConfig.java    License: Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Exposes configuration properties for Vert.x.
 *
 * @return The properties.
 */
@ConfigurationProperties("hono.vertx")
@Bean
public VertxProperties vertxProperties() {
    return new VertxProperties();
}
 
Example 30
Source Project: soul   Source File: WebsocketSyncDataConfiguration.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Config websocket config.
 *
 * @return the websocket config
 */
@Bean
@ConfigurationProperties(prefix = "soul.sync.websocket")
public WebsocketConfig websocketConfig() {
    return new WebsocketConfig();
}