dynamic-datasource不能识别mapper.xml(Invalidbound。。。

dynamic-datasource不能识别mapper.xml(Invalidbound。。。

2023年7月9日发(作者:)

dynamic-datasource不能识别(Invalidbound。。。下⾯这种配置⽅式是错误的mybatis-plus: mapper-locations: classpath:mapper/*.xml应该在config配置中配置xml路径@Configuration@EnableTransactionManagementpublic class MybatisPlusConfig { @Value("${}") private String url; @Value("${me}") private String username; @Value("${rd}") private String password; @Value("${-class-name}") private String driverClassName; /** * * @return

数据源配置 * @throws SQLException */ @Bean @Primary @ConfigurationProperties(prefix = "") public DataSource dataSourceMaster() throws SQLException { DruidDataSource dataSource = new DruidDataSource(); (url); ver(new DruidDriver().createDriver(driverClassName)); rname(username); sword(password); GlobalDataSourceStat(true); lPreparedStatements(true); idationQuery("select 1"); eBetweenEvictionRunsMillis(6000); return dataSource; } /** *

将默认数据源添加进动态数据源 * @param dataSourceMaster * @return */ @Bean("dynamicDataSource") public DataSource dynamicDataSource(DataSource dataSourceMaster) { MyDynamicRoutingDataSource dynamicRoutingDataSource = new MyDynamicRoutingDataSource(); aSource("master", dataSourceMaster); mary("master"); return dynamicRoutingDataSource; } @Bean @Primary @ConfigurationProperties(prefix = "mybatis") public MybatisSqlSessionFactoryBean sqlSessionFactoryBean(@Qualifier("dynamicDataSource") DataSource dataSource, @Qualifier("MybatisPlusInterceptor") MybatisPlusInterceptor mybatisPlusInterceptor) throws IOException { MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); aSource(dataSource); //关键代码,设置地址 perLocations(new PathMatchingResourcePatternResolver().getResources("classpath*:mapper/*.xml")); //分页插件 Interceptor[] plugins = new Interceptor[1]; Interceptor[] plugins = new Interceptor[1]; plugins[0] = mybatisPlusInterceptor; gins(plugins); return sqlSessionFactoryBean; } /** * myBatis-plus

分页查询配置 */ @Bean(name="MybatisPlusInterceptor") public MybatisPlusInterceptor MpPaginationInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); erInterceptor(new PaginationInnerInterceptor()); return interceptor; }}

发布者:admin,转转请注明出处:http://www.yc00.com/news/1688907506a182282.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信