# springboot的Crud **Repository Path**: dddjjj1234/crud_of_springboot ## Basic Information - **Project Name**: springboot的Crud - **Description**: No description available - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-10-22 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README pom org.springframework.boot spring-boot-starter-parent 1.5.15.RELEASE org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-jdbc com.zaxxer HikariCP mysql mysql-connector-java 6.0.5 org.springframework.boot spring-boot-starter-data-jpa 2.application.properties spring.datasource.url=jdbc:mysql://localhost:3306/mdstudent?useUnicode=true&characterEncoding=UTF-8&&serverTimezone=GMT%2B8&useSSL=false spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.jpa.show-sql =true server.port=80 3.DataSourceConfig import com.zaxxer.hikari.HikariDataSource; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import javax.sql.DataSource; @Configuration public class DataSourceConfig { @Bean("dataSource") public DataSource dataSource(Environment env){ HikariDataSource ds=new HikariDataSource(); ds.setJdbcUrl(env.getProperty("spring.datasource.url")); ds.setUsername(env.getProperty("spring.datasource.username")); ds.setPassword(env.getProperty("spring.datasource.password")); ds.setDriverClassName(env.getProperty("spring.datasource.driver-class-name")); return ds; } } 4.主键生成策略 @GeneratedValue(generator = "uuid2" ) //指定生成器名称 @GenericGenerator(name = "uuid2", strategy = "org.hibernate.id.UUIDGenerator" ) //生成器名称,uuid生成类 5.字符串转日期 /** * 将短时间格式字符串转换为时间 yyyy-MM-dd * * @param strDate * @return */ public static Date strToDate(String strDate) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; } 6.mysql插入行数修改 ... 1) 方法1 可以编辑my.cnf来修改(windows下my.ini),在[mysqld]段或者mysql的server配置段进行修改。 max_allowed_packet = 20M 2) 方法2 进入mysql server 在mysql 命令行中运行 set global max_allowed_packet = 210241024*10 然后关闭掉这此mysql server链接,再进入。 show VARIABLES like '%max_allowed_packet%'; 查看下max_allowed_packet是否编辑成功 ...