2020-09-09 17:35

小李子a DataSourceTransactionManager 这个问题怎么看,这样的用法我以前用jfinal 整合spring的时候也是没问题的,就是现在spingboot 整个独立ActiveRecord 包的时候碰到的问题

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 16:50

@小李子a 好的,我学习下,谢谢

2020-09-09 15:40

@JFinal 或者说是否可以在ActiveRecordPlugin 启动时加个方法让spring完全托管事务呢