1、在IDEA安装Easy Code插件
2、在IDEA中使用DateBase连接数据库
参考
语雀内容
3、生成逆向工程的代码
A.选择逆向的表结构
B.配置逆向生成的路径
C.提示创建不存在的包路径
D.逆向生成的分层
E.Dao层添加 @Mapper
注解
F.启动类添加 @MapperScan
注解进行Dao层接口扫描
G.在配置文件配置数据源信息-此处使用阿里的Druid数据源管理
①Druid的依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.13</version>
</dependency>
②数据源配置
mysql:
url: jdbc:mysql:///test?serverTimezone=UTC
username: root
password: 123456
driverClassName: com.mysql.cj.jdbc.Driver
spring:
application:
name: ServiceActiviti
datasource:
type: com.alibaba.druid.pool.DruidDataSource
url: ${mysql.url}
driver-class-name: ${mysql.driverClassName}
username: ${mysql.username}
password: ${mysql.password}
druid: # #
url: ${mysql.url}
username: ${mysql.username}
password: ${mysql.password}
driver-class-name: ${mysql.driverClassName}
initial-size: 10
max-active: 200
min-idle: 10
max-wait: 60000
pool-prepared-statements: false
validation-query: SELECT 1 FROM DUAL
test-on-borrow: false
test-on-return: false
test-while-idle: true
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 30000
max-pool-prepared-statement-per-connection-size: 20
aop-patterns: com.msyyt.crm.activity.*
filter: # 状态监控
stat:
enabled: true
db-type: mysql
log-slow-sql: true
slow-sql-millis: 2000
web-stat-filter: # 监控过滤器
enabled: true #是否启用 默认true
exclusions:
- '*.js'
- '*.gif'
- '*.jpg'
- '*.png'
- '*.css'
- '*.ico'
- /druid/*
stat-view-servlet: # druid 监控页面
enabled: true
url-pattern: /druid/*
reset-enable: false
allow: # 白名单
deny: # 黑名单
login-username: admin
login-password: admin
mybatis:
mapper-locations: classpath:/mapper/*Dao.xml
typeAliasesPackage: com.vue.demo.entity