码迷,mamicode.com
首页 > 数据库 > 详细

spring mysql多数据源配置

时间:2017-12-29 15:04:15      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:source   pre   多数据源   ica   word   uart   tab   pos   color   

spring mysql多数据源配置

 

@Configuration
public class QuartzConfig {

    @Autowired
    private AutowireJobFactory jobFactory;

    @Bean(name = "quartzDataSource")
    @ConfigurationProperties(prefix="spring.datasource.quartz")
    public DataSource quartzDataSource() {
        return DataSourceBuilder.create().build();
    }

    private Properties quartzProperties() {
        Properties properties = new Properties();
        properties.put("org.quartz.jobStore.tablePrefix", "DC_QRTZ_");
        return properties;
    }

    @Bean
    public SchedulerFactoryBean schedulerFactoryBean() {
        SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
        schedulerFactoryBean.setJobFactory(jobFactory);
        schedulerFactoryBean.setDataSource(quartzDataSource());
        schedulerFactoryBean.setQuartzProperties(quartzProperties());
        return schedulerFactoryBean;
    }

    @Bean
    public Scheduler scheduler() {
        return schedulerFactoryBean().getScheduler();
    }

}

 

application.properties

# quartz datasource
spring.datasource.quartz.url=jdbc:mysql://rds.aliyuncs.com:3306/iotx-data-center-meta
spring.datasource.quartz.username=dataservice
spring.datasource.quartz.password=Data12345
spring.datasource.quartz.driver-class-name=com.mysql.jdbc.Driver

 

spring mysql多数据源配置

标签:source   pre   多数据源   ica   word   uart   tab   pos   color   

原文地址:https://www.cnblogs.com/diegodu/p/8143790.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!