spring boot + dubbo+zk集成,所踩过的坑汇总

1、简单框架搭建,没有涉及到数据库,只是搭建了api、provider、consumer三个工程,首先启动了zk,再启动

服务提供者provider工程时报错:Cannot determine embedded database driver class for database type NONE

原因是:springboot启动时会自动注入数据源和配置jpa

解决办法一:启动类中加入注解:@SpringBootApplication(exclude={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class})
解决方法二:在Application.properties文件内配置数据源即可。代码如下:(方法二未测试,方法一亲测有效
  1. spring.datasource.url=jdbc:mysql://localhost:3306/test  
  2. spring.datasource.username=root  
  3. spring.datasource.password=123456  
  4. spring.datasource.driver-class-name=com.mysql.jdbc.Driver  
  5. spring.datasource.max-idle=10  
  6. spring.datasource.max-wait=10000  
  7. spring.datasource.min-idle=5  
  8. spring.datasource.initial-size=5  


2、spring boot项目的实体类必须实现Seriabilizable接口。并且添加private static final long serialVersionUID = -4813361542496370884L;属性。


3、spring boot 集成mybatis:

    3.1、报错:class path resource [mapper/*.xml] cannot be opened because it does not exist

    原因是在,application.ym配置文件中引入xml文件的属性写错了,写成了mybatis: config-location: classpath:mapper/*.xml,应该是mapper-locations: classpath:mybatis/**/*.xml

    3.2、关于扫描mapper接口类的方式有两种,一是在application.java启动类上加@MapperScan("com.lsl.springboot_01.mapper"),另一种是在每个接口mpper上加@Mapper注解。

 
  

你可能感兴趣的:(JAVA,EE)