天天看點

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

    3.2、關于掃描mapper接口類的方式有兩種,一是在application.java啟動類上加@MapperScan("com.lsl.springboot_01.mapper"),另一種是在每個接口mpper上加@Mapper注解。

繼續閱讀