springboot连接mysql数据库
- pom.xml配置
- application.yml配置
pom.xml配置
4.0.0
com.jt
jt
1.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
2.5.3
1.8
true
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-test
test
org.projectlombok
lombok
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-jdbc
com.baomidou
mybatis-plus-boot-starter
3.4.3
net.bytebuddy
byte-buddy
org.springframework.boot
spring-boot-maven-plugin
2.5.3
application.yml配置
server:
port: 8080
#配置数据源
spring:
datasource:
#如果使用高版本驱动 则添加cj
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/jt?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true
username: root
password: 123456
#mybatis-plush配置
mybatis-plus:
type-aliases-package: com.jt.pojo
mapper-locations: classpath:/mappers/*.xml
configuration:
map-underscore-to-camel-case: true