当前使用版本(必填,否则不予处理)
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version> 3.4.2</version>
</dependency>
该问题是如何引起的?(确定最新版也有问题再提!!!)
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version> 3.4.2</version>
</dependency>
重现步骤(如果有就写完整)
-
数据源配置: @Bean(initMethod = "init") @ConfigurationProperties(prefix = "spring.datasource") public DruidDataSource dataSource() { DruidDataSource druidDataSource = new DruidDataSource(); return druidDataSource;
}
@Bean("dataSourceProxy") public TxcDataSource dataSourceProxy(DruidDataSource dataSource) { return new TxcDataSource(dataSource); }
@Bean("jdbcTemplate") @ConditionalOnBean(TxcDataSource.class) public JdbcTemplate jdbcTemplate(TxcDataSource dataSourceProxy) { return new JdbcTemplate(dataSourceProxy); }
@Bean public SqlSessionFactory sqlSessionFactory(TxcDataSource dataSourceProxy) throws Exception { MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); factoryBean.setDataSource(dataSourceProxy); factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver() .getResources("classpath:/config/mapper/.xml")); factoryBean.setPlugins(new Interceptor[]{new PaginationInterceptor()});
return factoryBean.getObject();} @Bean @ConditionalOnBean(TxcDataSource.class) public PlatformTransactionManager exampleTransactionManager(TxcDataSource txcDataSource) { DataSourceTransactionManager txManager = new DataSourceTransactionManager(); txManager.setDataSource(txcDataSource); return txManager; } 2. 在service的函数里添加 @Transactional 调用this.saveBatch(result);
报错信息
Error flushing statements. Cause: java.sql.SQLException: java.sql.SQLException: registTrxBranch error XXXX
message:Transaction 216815689 doesn't exist
Comment From: huayanYu
如果mybatis支持,则我们支持。