abbott_001 2021-12-17 19:01 采纳率: 42.9%
浏览 30
已结题

springboot+maven 多模块项目中引入多数据源dynamic-datasource问题

原有springboot+maven多模块项目中,想增加获取另一个数据库的数据,于是增加了dynamic-datasource

的配置,如下:

主pom.xml中增加配置:

      <dependency>
          <groupId>com.baomidou</groupId>
          <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
          <version>2.5.7</version>
      </dependency>

启动类中增加:
 EnableTransactionManagement
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
@EnableScheduling
@MapperScan(basePackages = {"com.xxx.mapper"})
public class RapidoRestApplication extends SpringBootServletInitializer {


yml配置文件如下:
datasource:
    dynamic:
      ##默认的数据源
      primary: master
      datasource:
        master: #唯一标识  你原来的数据源放在这里个里面
          url: jdbc:mysql://192.168.****:3306/rap?autoReconnect=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&&useSSL=false
          username: rap
          password: 123456
          type: com.alibaba.druid.pool.DruidDataSource
          driverClassName: com.mysql.cj.jdbc.Driver  #这是驱动8.0的,以前版本的记得换
        s_log: #唯一标识 日志数据源
          url: jdbc:mysql://10.12.0.10:3306/resdb?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
          username: root
          password: 123456
          type: com.alibaba.druid.pool.DruidDataSource
          driverClassName: com.mysql.cj.jdbc.Driver #这是驱动8.0的,以前版本的记得换
    filters: stat
    maxActive: 200
    initialSize: 30
    maxWait: 60000
    minIdle: 10
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select 'x'
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20

配置完成后,启动服务报错,如下:

Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

2021-12-17 18:58:54.388 [Thread-4] ERROR com.ftsafe.rest.client.ChatClient - executor not accepting a task
java.lang.IllegalStateException: executor not accepting a task
at io.netty.resolver.AddressResolverGroup.getResolver(AddressResolverGroup.java:60)
at io.netty.bootstrap.Bootstrap.doResolveAndConnect0(Bootstrap.java:200)
at io.netty.bootstrap.Bootstrap.access$000(Bootstrap.java:49)
at io.netty.bootstrap.Bootstrap$1.operationComplete(Bootstrap.java:188)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月25日
    • 修改了问题 12月17日
    • 修改了问题 12月17日
    • 修改了问题 12月17日
    • 展开全部

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算