介绍
- 测试发现实体基类种的时间格式不能在 MySQL5.5及其一下不能使用
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
- 原因
- MySql 5.5和MySql 5.6之后版本的区别:5.5 只能有一个Timestamp
- 解决
- 将其中一列类型改为datetime类型
- 不用5.5数据库
- 不用自带的实体基类
-
引入依赖
```xml <?xml version=”1.0” encoding=”UTF-8”?> <project xmlns=”http://maven.apache.org/POM/4.0.0“ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance“
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0 org.springframework.boot spring-boot-starter-parent 2.4.1 com.example mysql-jpa-timestamp 0.0.1-SNAPSHOT mysql-jpa-timestamp 测试不同数据库的时间戳问题 1.8 org.springframework.boot spring-boot-starter-web com.detabes caches-jpa-server 1.0.0 mysql mysql-connector-java org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-maven-plugin
<a name="B7oCq"></a>
# 开始配置
```yaml
spring.profiles.active=57
application-55.ymlapplication-57.ymlapplication-80.yml