基于mybatis-plus的单数据应用。
1.引入依赖
<dependency>
<groupId>com.xy</groupId>
<artifactId>xy-core-framework-dal-standalone-monitor</artifactId>
<version>${xy-core-framework-dal-standalone.version}</version>
</dependency>
2.添加配置
spring.datasource.url=jdbc:mysql://localhost:3306/company-demo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
#spring.datasource.url=jdbc:postgresql://localhost:5432/company-demo?stringtype=unspecified
spring.datasource.type=com.zaxxer.hikari.HikariDataSource
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
#spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.username=root
#### 1q2w3e4r@
spring.datasource.password=1q2w3e4r@
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.minimum-idle=3
spring.datasource.hikari.idle-timeout=600000
spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.max-lifetime=28740000
spring.datasource.hikari.connection-test-query=SELECT 1
spring.datasource.hikari.allow-pool-suspension=false
spring.datasource.hikari.auto-commit=true
spring.datasource.hikari.connection-init-sql=SET NAMES utf8mb4
3.编码使用
正常编码就行,事务就是spring的原生事务