springcloud mysql操作的最佳实践
2017-12-02 16:53
495 查看
springcloud mysql配置
datasource: driver-class-name: com.mysql.jdbc.Driver username: root password: 123456 url: jdbc:mysql://***/dbname?characterEncoding=utf-8&useSSL=false //防止乱码
mysql时间字段在对象save时自动更新配置
updateTime数据库mysql5.7设置为自动更新 create table `product_category` ( `category_id` int not null auto_increment, `category_name` varchar(64) not null comment '类目名字', `category_type` int not null comment '类目编号', `create_time` timestamp not null default current_timestamp comment '创建时间', `update_time` timestamp not null default current_timestamp on update current_timestamp comment '修改时间', primary key (`category_id`) );
@Entity @DynamicUpdate //不加注解,对象save时updateTime不会自动更新 @Data public class ProductCategory { /** 类目id. */ @Id @GeneratedValue private Integer categoryId; /** 类目名字. */ private String categoryName; /** 类目编号. */ private Integer categoryType; private Date createTime; private Date updateTime; public ProductCategory() { } public ProductCategory(String categoryName, Integer categoryType) { this.categoryName = categoryName; this.categoryType = categoryType; } }
相关文章推荐
- 【Rainbond最佳实践】Spring Boot框架配置MySQL
- Spring Cloud Eureka 全解 (7) - 生产配置最佳实践
- mysql原生在线DDL修改主键操作的最佳实践
- MySQL性能优化的21个最佳实践 和 mysql使用索引
- RabbitMQ实践--与Spring的简单整合操作
- Spring中利用JDBC模板完成SQLServer数据库(MySQL一样)各种操作
- MySQL 升级的最佳实践
- Struts2、Spring、Hibernate 高效开发的最佳实践
- spring boot 最佳实践(二)--使用Bean Validation
- javax.validation结合spring最佳实践
- ASP.NET&Spring.NET&NHibernate最佳实践(十四)——第4章权限子系统(7)
- ASP.NET&Spring.NET&NHibernate最佳实践(二十四)——第4章权限子系统(17)
- Struts2、Spring、Hibernate 高效开发的最佳实践
- 《Spring 2.0核心技术与最佳实践》即将上市
- Spring Cloud + Kubernetes 微服务框架原理和实践
- azure 最佳实践 3--最小协同操作
- 基于Spring Boot、Spring Cloud、Docker的微服务系统架构实践
- mysql:21个性能优化最佳实践之5[在Join表的时候使用相当类型的列,并将其索引]