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文件内配置数据源即可。代码如下:(方法二未测试,方法一亲测有效)
- 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
3.2、关于扫描mapper接口类的方式有两种,一是在application.java启动类上加@MapperScan("com.lsl.springboot_01.mapper"),另一种是在每个接口mpper上加@Mapper注解。