问题随记
- Spring Boot通过Mybatis,使用mapper接口和xml配置sql,连接数据库
首先在配置文件application.properties
1
2
3
4
5
6
7
8
9
10jdbc:mysql://localhost:3306/test =
*** =
*** =
com.mysql.jdbc.Driver =
#mybatis.typeAliasesPackage:为实体对象所在的包,跟数据库表一一对应
#mybatis.mapperLocations:mapper文件的位置
com.xxx.model =
classpath:mybatis/mapper/*Mapper.xml =在启动类Application.java中写上配置信息
1
2
3
4
5
6
7
8
// mybatis扫描路径,针对的是接口Mapper类
public class DailyreportApplication{
public static void main(String[] args) {
SpringApplication.run(DailyreportApplication.class, args);
}
}
- mysql连接异常
java.sql.SQLException: Value '0000-00-00' can not be represented as java.sql.Date
- 解决办法
jdbc:mysql://yourserver:3306/yourdatabase?zeroDateTimeBehavior=convertToNull