vault backup: 2026-11-07 16:33:44
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
|
||||
|
||||
```Plain Text
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.9</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
springboot 2.3.4.Release版本配置文件配置
|
||||
|
||||
```Plain Text
|
||||
spring:
|
||||
datasource:
|
||||
username: root
|
||||
password: root
|
||||
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2B8
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
#项目启动执行建表语句,classpath指定sql文件的位置
|
||||
schema:
|
||||
- classpath:sql/init.sql
|
||||
initialization-mode: always
|
||||
platform: mysql
|
||||
sql-script-encoding: UTF-8
|
||||
```
|
||||
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
springboot 2.6.4版本配置文件配置(谢谢nreg的指出)
|
||||
|
||||
spring:
|
||||
sql:
|
||||
init:
|
||||
separator: ; #断句分隔符,默认为 ; 号,如果执行语句中有 存储过程 或 游标 这种 则需要更改
|
||||
encoding: UTF-8
|
||||
platform: sqlite #默认值为all 在不同数据库切换的情况下才使用 all 配置,spring boot 会自动检测当前使用的数据库
|
||||
mode: always # 初始化模式,有三个值:always:始终执行初始化、embedded:只初始化内存数据库(默认)、never:不执行初始化
|
||||
schema-locations: #表初始化语句 DDL,默认加载 schema.sql
|
||||
- classpath:sql/schema.sql
|
||||
data-locations: #数据初始化 DQL(数据查询)或 DML(数据操作),默认加载 data.sql,
|
||||
- classpath:sql/data.sql
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
sql文件填写
|
||||
|
||||
---
|
||||
|
||||
-- Table structure for t1
|
||||
|
||||
---
|
||||
|
||||
DROP TABLE IF EXISTS `t1`;
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
|
||||
|
||||
---
|
||||
|
||||
-- Records of t1
|
||||
|
||||
---
|
||||
|
||||
INSERT INTO `t1` VALUES (1, '1');
|
||||
INSERT INTO `t1` VALUES (2, '2');
|
||||
INSERT INTO `t1` VALUES (3, '3');
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
————————————————
|
||||
版权声明:本文为CSDN博主「知识浅谈」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
|
||||
原文链接:[https://blog.csdn.net/qq_37699336/article/details/119877899](https://blog.csdn.net/qq_37699336/article/details/119877899)
|
||||
|
||||
Reference in New Issue
Block a user