基础环境
SpringBoot : 3.0.0
Java: jdk-17.0.5
Maven: 3.6.1
引入相关jar
<?xml version="1.0" encoding="UTF-8"?>
< project xmlns = " http://maven.apache.org/POM/4.0.0" xmlns: xsi= " http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation= " http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" > < modelVersion> 4.0.0</ modelVersion> < parent> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-parent</ artifactId> < version> 3.0.0-SNAPSHOT</ version> < relativePath/> </ parent> < groupId> com.giser</ groupId> < artifactId> gis-java-mp</ artifactId> < version> 0.0.1-SNAPSHOT</ version> < name> gis-java-mp</ name> < description> Demo project for Spring Boot</ description> < properties> < java.version> 17</ java.version> </ properties> < dependencies> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-web</ artifactId> </ dependency> < dependency> < groupId> com.baomidou</ groupId> < artifactId> mybatis-plus-boot-starter</ artifactId> < version> 3.5.3</ version> < exclusions> < exclusion> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-jdbc</ artifactId> </ exclusion> </ exclusions> </ dependency> < dependency> < groupId> com.baomidou</ groupId> < artifactId> dynamic-datasource-spring-boot-starter</ artifactId> < version> 3.6.1</ version> < exclusions> < exclusion> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-aop</ artifactId> </ exclusion> < exclusion> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-jdbc</ artifactId> </ exclusion> </ exclusions> </ dependency> < dependency> < groupId> com.baomidou</ groupId> < artifactId> mybatis-plus-generator</ artifactId> < version> 3.5.3</ version> </ dependency> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-jdbc</ artifactId> < version> 2.1.3.RELEASE</ version> </ dependency> < dependency> < groupId> mysql</ groupId> < artifactId> mysql-connector-java</ artifactId> < version> 8.0.16</ version> </ dependency> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-freemarker</ artifactId> < version> 3.1.5</ version> </ dependency> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-web</ artifactId> </ dependency> < dependency> < groupId> org.projectlombok</ groupId> < artifactId> lombok</ artifactId> < optional> true</ optional> </ dependency> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-starter-test</ artifactId> < scope> test</ scope> </ dependency> < dependency> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-autoconfigure</ artifactId> < version> 3.0.0</ version> </ dependency> </ dependencies> < build> < finalName> gis-mp</ finalName> < plugins> < plugin> < groupId> org.springframework.boot</ groupId> < artifactId> spring-boot-maven-plugin</ artifactId> < version> 2.5.4</ version> < configuration> < mainClass> com.giser.mp.GisJavaMpApplicationTests</ mainClass> </ configuration> </ plugin> </ plugins> </ build> </ project>
数据源等配置
server : port : 9999 servlet : context-path : /encoding : charset : UTF- 8 spring : datasource : params : useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=GMT%2B8 dynamic : primary : masterstrict : false datasource : master : url : jdbc: mysql: //ip: port/dbname? ${ spring.datasource.params} username : dbusernamepassword : dbpasswordslave : url : jdbc: mysql: //ip: port/dbname? ${ spring.datasource.params} username : dbusernamepassword : dbpasswordhikari : max-lifetime : 18000 connection-timeout : 10000 idle-timeout : 3600000 min-idle : 4 max-pool-size : 12