目前由下到上划分了几个模块:
common : 常用比如工具类等
core : 打算用来放一些系统级别相关的类,配置等
dao : 数据层
service : 服务层
web : 前后端分离的话主要就剩下Controller了
下面是项目和每个模块的pom
项目的pom
需要注意的是packaging为pom。
声明每个子模块。
打包使用的插件,暂时还没深入了解,理解应该有错误。
目前我知道的是要打成war包的话,需要SpringBoot帮忙生成WEB-INF, DispatcherServlet等,所以得用spring-boot-maven-plugin。
网上还看到说打包成war还需要排除springboot的内置tomcat,我测试了下没排除的话,没发现什么影响。
<?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>2.2.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.funwe</groupId>
<artifactId>spfun</artifactId>
<version>0.0.1</version>
<name>spfun</name>
<description>spfun</description>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<!-- 子模块 -->
<modules>
<module>common</module>
<module>core</module>
<module>dao</module>
<module>service</module>
<module>web</module>
</modules>
<!-- 依赖 -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Web打成JAR包运行时使用 -->
<!--
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${
java.version}</source>
<target>${
java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>