多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
步骤如下: **1. 创建一个SpringBoot项目** ```xml <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.23</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.13</version> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.16</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.24</version> </dependency> </dependencies> ``` **2. `resources/application.yml`** ```yml spring: datasource: url: jdbc:mysql://localhost:3306/springdatajpa?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: uhg</flEt3dff driver-class-name: com.mysql.cj.jdbc.Driver type: com.alibaba.druid.pool.DruidDataSource jpa: #使用mysql数据库 database: mysql #数据库引擎为InnoDB database-platform: org.hibernate.dialect.MySQL5InnoDBDialect #控制台输出正在执行的SQL语句 show-sql: true hibernate: #create:每次运行程序时,都会重新创建表,故而数据会丢失 #create-drop:每次运行程序时会先创建表结构,然后待程序结束时清空表 #upadte:每次运行程序,没有表时会创建表,如果对象发生改变会更新表结构,原有数据不会清空,只会更新(推荐使用) #validate:运行程序会校验数据与数据库的字段类型是否相同,字段不同会报错 #none: 禁用DDL处理 ddl-auto: update ``` **3. 环境搭建完成**