1.创建新项目repo-modele
2.右键Repo_modele -> New -> Module…->next
分别创建bs-web,bs-service,bs-entity,bs-mapper四个模块
3.父模块核心
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>Repo_modele</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
<module>bs-web</module>
<module>bs-service</module>
<module>bs-mapper</module>
<module>bs-entity</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.6.RELEASE</version>
</parent>
<properties>
<bs-web>1.0-SNAPSHOT</bs-web>
<bs-mapper>1.0-SNAPSHOT</bs-mapper>
<bs-service>1.0-SNAPSHOT</bs-service>
<bs-mapper>1.0-SNAPSHOT</bs-mapper>
<bs-model>1.0-SNAPSHOT</bs-model>
<bs-entity>1.0-SNAPSHOT</bs-entity>
<mysql-connector-java>8.0.19</mysql-connector-java>
<mybatis-spring-starter-boot>2.1.4</mybatis-spring-starter-boot>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.itz</groupId>
<artifactId>bs-service</artifactId>
<version>${bs-service}</version>
</dependency>
<dependency>
<groupId>com.itz</groupId>
<artifactId>bs-mapper</artifactId>
<version>${bs-mapper}</version>
</dependency>
<dependency>
<groupId>com.itz</groupId>
<artifactId>bs-web</artifactId>
<version>${bs-web}</version>
</dependency>
<dependency>
<groupId>com.itz</groupId>
<artifactId>bs-entity</artifactId>
<version>${bs-entity}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-starter-boot}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector-java}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.6.RELEASE</version>
</plugin>
</plugins>
</build>
</project>
4.子模块引入另外一个子模块中的类
5.在bs-web项目中创建启动类
@SpringBootApplication
@MapperScan(value = "com.itz")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
6.application.yaml
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: hao20001010
url: jdbc:mysql:localhost:3306/crud?serverTimezone=UTC
mybatis:
mapper-locations: mapper/*.xml
type-aliases-package: com.itz
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl