单体应用-SpringBoot-(1)划分模块

几乎完全参考自SpringBoot+Maven多模块项目(创建、依赖、打包可执行jar包部署测试)完整流程

目前由下到上划分了几个模块:
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>
                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值