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注解。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一路奔跑1314

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值