1、简单框架搭建,没有涉及到数据库,只是搭建了api、provider、consumer三个工程,首先启动了zk,再启动
服务提供者provider工程时报错:Cannot determine embedded database driver class for database type NONE
原因是:springboot启动时会自动注入数据源和配置jpa
- spring.datasource.url=jdbc:mysql://localhost:3306/test
- spring.datasource.username=root
- spring.datasource.password=123456
- spring.datasource.driver-class-name=com.mysql.jdbc.Driver
- spring.datasource.max-idle=10
- spring.datasource.max-wait=10000
- spring.datasource.min-idle=5
- 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注解。