2020-09-09 16:53
@小李子a http://jfinal.com/share/1867 这上面讲的我看,我用的就是这种方式,还是不生效的,如下是我的代码
@Slf4j
@EnableTransactionManagement
@Configuration
public class DruidDataSourceConfig {
@Bean(name = "dataSourceDb1")
@Primary
@ConfigurationProperties("spring.datasource.druid.one")
public DataSource dataSourceDb1() {
DruidDataSource druidDataSource = new DruidDataSourceWrapper();
log.info("druidDataSource.dataSourceDb1 loaded......");
return druidDataSource;
}
@Bean(name = "dataSourceProxy")
public TransactionAwareDataSourceProxy dataSourceProxy() {
log.info("TransactionAwareDataSourceProxy loaded......");
return new TransactionAwareDataSourceProxy(dataSourceDb1());
}
@Bean(name = "transactionManager")
public PlatformTransactionManager transactionManager() {
log.info("PlatformTransactionManager loaded......");
return new DataSourceTransactionManager(dataSourceProxy());
}
}
-----------------------------------------------------------------------------------
ActiveRecordPlugin arp = new ActiveRecordPlugin(dataSourceProxy);
boolean showSqlb = "true".equals(showSql) ? true : false;
arp.setShowSql(showSqlb);
addMappings(arp);
arp.start();
2020-09-09 15:40
@JFinal 或者说是否可以在ActiveRecordPlugin 启动时加个方法让spring完全托管事务呢