admin 管理员组文章数量: 887021
2024年2月20日发(作者:进程管理与处理机管理一样吗)
import ataSource;import ataSourceBuilder;import tatProperties;import ;import urceType;import roperties;import cDataSource;import Utils;import AsyncExecutor;import ProcessEngineConfiguration;import ctProcessEngineAutoConfiguration;import ionalOnProperty;import urationProperties;import RegistrationBean;import ;import uration;import y;import rmTransactionManager;import t.*;import urce;import ption;import p;import ;/** * druid 配置多数据源 * * @author xxx */@Configurationpublic class DruidConfig extends AbstractProcessEngineAutoConfiguration { @Bean @ConfigurationProperties("") public DataSource systemDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean @ConfigurationProperties("ti") @ConditionalOnProperty(prefix = "ti", name = "enabled", havingValue = "true") public DataSource activitiDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean @ConfigurationProperties("sm") @ConditionalOnProperty(prefix = "sm", name = "enabled", havingValue = "true") public DataSource allelismDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean @ConfigurationProperties("te") @ConditionalOnProperty(prefix = "te", name = "enabled", havingValue = "true") public DataSource templateDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); }
@Bean @ConfigurationProperties("") @ConditionalOnProperty(prefix = "", name = "enabled", havingValue = "true") public DataSource logDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean @ConfigurationProperties("") @ConditionalOnProperty(prefix = "", name = "enabled", havingValue = "true") public DataSource eventDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean @ConfigurationProperties("") @ConditionalOnProperty(prefix = "", name = "enabled", havingValue = "true") public DataSource statisDataSource(DruidProperties druidProperties) { DruidDataSource dataSource = ().build(); return urce(dataSource); } @Bean(name = "dynamicDataSource") @Primary public DynamicDataSource dataSource(DataSource systemDataSource) { Map
}讲解:ProceedingJoinPoint get().getClass();otation()获取当前注解动态数据源import ctRoutingDataSource;import urce;import ;/** * 动态数据源 * * @author xxx */public class DynamicDataSource extends AbstractRoutingDataSource{ public DynamicDataSource(DataSource defaultTargetDataSource, Map
版权声明:本文标题:多数据源动态切换自定义注解方式 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1708360760h521381.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论