Consider the following: If you want an embedded database (H2, HSQL or Derby), please put it on the

**      出现这个情况是微服务直接或者间接引用了myabtis/mybatis-plus的依赖,引用了myabtis的依赖后他会读取数据源相关的配置,但是yml没配置或者说当前微服务不需要配置,但是框架检测到没写,就会问是不是要加载springboot内置的h2等数据源

解决方式有三种:
      1.直接利用maven的排除依赖,排除掉myabtis/mybatis-plus的依赖
如当前的数据源是从其他地方继承过来的,那就在继承的dependency标签中排除
      2.启动类注解修改@SpringBootApplication(exclude = DataSourceAutoConfiguration.class),因为主启动类本身就是一个spring配置类,所以我们在里面排除依赖也可以
      3.报错了,我们就配置个数据源,尽管我们不需**要

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    username: root
    password: root
    url: jdbc:mysql://192.168.56.10:3306/gulimall_sms

你可能感兴趣的:(java,java,idea,spring,boot)