springboot模块化父子项目搭建pom 及打包

news/2025/2/12 7:59:49/

父项目

父项目 不做任何代码处理,只管理其他模块,
它的父项目继承springboot
它有自己的 用于子模块引用
它的打包方式为pom
它的<> 管理所有公共jar 版本
它的 管理所有公共jar
它的 管理所有模块

<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><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.2.1.RELEASE</version><relativePath /> <!-- lookup parent from repository --></parent><groupId>com.xiaoben</groupId><artifactId>nuxtjs-server</artifactId><version>0.0.1-SNAPSHOT</version><packaging>pom</packaging><name>nuxtjs-server</name><url>http://maven.apache.org</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><druid.version>1.2.8</druid.version><java.version>1.8</java.version><mybatisplus.version>3.4.3.2</mybatisplus.version><fastjson.version>1.2.78</fastjson.version><log4j.version>1.2.17</log4j.version><shiro.version>1.6.0</shiro.version><hutool.version>5.7.13</hutool.version><pinyin4j.version>2.5.1</pinyin4j.version><poi.version>4.0.0</poi.version><jjwt.version>0.11.2</jjwt.version></properties><dependencies><dependency><groupId>com.github.yulichang</groupId><artifactId>mybatis-plus-join</artifactId><version>1.2.2</version></dependency><dependency><groupId>org.apache.shiro</groupId><artifactId>shiro-spring</artifactId><version>1.3.2</version></dependency><!-- google图片处理 --><dependency><groupId>net.coobird</groupId><artifactId>thumbnailator</artifactId><version>0.4.11</version></dependency><!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all --><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>${hutool.version}</version></dependency><!--redis--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.session</groupId><artifactId>spring-session-data-redis</artifactId></dependency><!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<!--		<dependency>-->
<!--			<groupId>cn.hutool</groupId>-->
<!--			<artifactId>hutool-all</artifactId>-->
<!--			<version>5.7.13</version>-->
<!--		</dependency>--><!--jwt--><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-api</artifactId><version>${jjwt.version}</version></dependency><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-impl</artifactId><version>${jjwt.version}</version><scope>runtime</scope></dependency><dependency><groupId>io.jsonwebtoken</groupId><artifactId>jjwt-jackson</artifactId><version>${jjwt.version}</version><scope>runtime</scope></dependency><!-- https://mvnrepository.com/artifact/com.google.zxing/core --><dependency><groupId>com.google.zxing</groupId><artifactId>core</artifactId><version>3.4.1</version></dependency><dependency><groupId>com.google.zxing</groupId><artifactId>javase</artifactId><version>3.4.1</version></dependency><!--poi--><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml</artifactId><version>${poi.version}</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi</artifactId><version>${poi.version}</version></dependency><dependency><groupId>org.apache.poi</groupId><artifactId>poi-ooxml-schemas</artifactId><version>${poi.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-aop</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-jdbc</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>joda-time</groupId><artifactId>joda-time</artifactId></dependency><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>${mybatisplus.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>${druid.version}</version></dependency><!-- fastJson --><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>${fastjson.version}</version></dependency><!-- https://mvnrepository.com/artifact/org.projectlombok/lombok --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.20</version><scope>provided</scope></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><scope>runtime</scope></dependency><dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></dependency><!-- swagger --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version><exclusions><exclusion><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId></exclusion></exclusions></dependency><dependency><groupId>io.swagger</groupId><artifactId>swagger-models</artifactId><version>1.6.0</version></dependency><!-- swagger-ui --><dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version></dependency><dependency><groupId>com.github.xiaoymin</groupId><artifactId>swagger-bootstrap-ui</artifactId><version>1.9.0</version></dependency><!--log4j --><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>${log4j.version}</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency><dependency><groupId>org.apache.httpcomponents</groupId><artifactId>httpclient</artifactId><version>4.5.13</version></dependency><!-- sql 打印 --><dependency><groupId>p6spy</groupId><artifactId>p6spy</artifactId><version>3.8.1</version></dependency></dependencies><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.22.2</version><configuration><skipTests>true</skipTests></configuration></plugin></plugins></build><modules><module>nuxt.entity</module><module>nuxt.service</module><module>nuxt.common</module><module>nuxt.app</module></modules>
</project>

dao层 service层 common层 都是公用的不需要打包

dao 即entity

<?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>com.xiaoben</groupId><artifactId>nuxtjs-server</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>nuxt.entity</artifactId></project>

service
需要依赖dao 即entity 和common

<?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>com.xiaoben</groupId><artifactId>nuxtjs-server</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>nuxt.service</artifactId><dependencies><dependency><groupId>com.xiaoben</groupId><artifactId>nuxt.entity</artifactId><version>${project.version}</version></dependency><dependency><groupId>com.xiaoben</groupId><artifactId>nuxt.common</artifactId><version>${project.version}</version></dependency></dependencies>
</project>

common

<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>com.xiaoben</groupId><artifactId>nuxtjs-server</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>nuxt.common</artifactId><dependencies><dependency><groupId>com.hazrxxframework</groupId><artifactId>hazrxx-wxpay</artifactId><version>1.1.6-RELEASES</version><scope>system</scope><systemPath>${project.basedir}/lib/hazrxx-wxpay-1.1.6-RELEASES.jar</systemPath></dependency><dependency><groupId>com.hazrxxframework</groupId><artifactId>hazrxx-annotation</artifactId><version>1.0.3-RELEASES</version><scope>system</scope><systemPath>${project.basedir}/lib/hazrxx-annotation-1.0.3-RELEASES.jar</systemPath></dependency><dependency><groupId>com.xiaoben</groupId><artifactId>nuxt.entity</artifactId><version>${project.version}</version></dependency><dependency><groupId>com.sun.mail</groupId><artifactId>javax.mail</artifactId><version>1.6.0</version></dependency></dependencies>
</project>

业务层 controller

打包方式jar
需要依赖service和

<?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>com.xiaoben</groupId><artifactId>nuxtjs-server</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>nuxt.app</artifactId><packaging>jar</packaging><dependencies><dependency><groupId>com.xiaoben</groupId><artifactId>nuxt.service</artifactId><version>${project.version}</version></dependency><dependency><groupId>org.bouncycastle</groupId><artifactId>bcprov-jdk15on</artifactId><version>1.56</version></dependency><!-- 开发测试期间用的生成地区拼音 --><dependency><groupId>com.belerweb</groupId><artifactId>pinyin4j</artifactId><version>2.5.1</version><scope>test</scope></dependency><dependency><groupId>com.thoughtworks.xstream</groupId><artifactId>xstream</artifactId><version>1.4.7</version> </dependency><dependency><groupId>net.sf.json-lib</groupId><artifactId>json-lib</artifactId><version>2.2.2</version><classifier>jdk15</classifier></dependency><dependency><groupId>dom4j</groupId><artifactId>dom4j</artifactId><version>1.6.1</version></dependency></dependencies><build><finalName>htyx.app</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version><configuration><encoding>UTF-8</encoding><nonFilteredFileExtensions><nonFilteredFileExtension>pfx</nonFilteredFileExtension><nonFilteredFileExtension>keystore</nonFilteredFileExtension></nonFilteredFileExtensions></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><!-- 你的主类全路径 --><mainClass>com.xiaoben.nuxt.AppApiApplication</mainClass><includeSystemScope>true</includeSystemScope></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>
</project>

最后启动类上写上

@CrossOrigin(origins = {"*"})//跨域
@SpringBootApplication(scanBasePackages={"com.xiaoben.nuxt"})//扫描所有配置文件
@MapperScan(basePackages = {"com.xiaoben.nuxt.mapper"})//扫描mapper
@EnableWebMvc
@EnableSwagger2 //没有配置类的Swagger需要加
@EnableSwaggerBootstrapUI//没有配置类的Swagger需要加

打包

父项目支持打包 但没有启动类

	<configuration><skipTests>true</skipTests></configuration>
<build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>2.22.2</version><configuration><skipTests>true</skipTests></configuration></plugin></plugins></build>

app 打包 有启动类

<configuration><!-- 你的主类全路径 --><mainClass>com.xiaoben.nuxt.AppApiApplication</mainClass><includeSystemScope>true</includeSystemScope></configuration>
<build><finalName>htyx.app</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><artifactId>maven-resources-plugin</artifactId><version>3.0.2</version><configuration><encoding>UTF-8</encoding><nonFilteredFileExtensions><nonFilteredFileExtension>pfx</nonFilteredFileExtension><nonFilteredFileExtension>keystore</nonFilteredFileExtension></nonFilteredFileExtensions></configuration></plugin><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><!-- 你的主类全路径 --><mainClass>com.xiaoben.nuxt.AppApiApplication</mainClass><includeSystemScope>true</includeSystemScope></configuration><executions><execution><goals><goal>repackage</goal></goals></execution></executions></plugin></plugins></build>

dao层 service层 common层 不配置 也可以直接打 (有人说父依赖不配置也可以 这个我没试过)

最后点击idea侧边栏 maven package 进行打包 (第一次可能要install)


http://www.ppmy.cn/news/496761.html

相关文章

同放在袋子里

我在外读书工作&#xff0c;有几年很忙、也很荒唐&#xff0c;竟然两三年没有回家过年。&#xff08;因为每年年初四&#xff0c;我就必须出现在湖南&#xff0c;然后行走在列车上和各个车站&#xff0c;一直到年十六十七&#xff0c;天天看着新闻联播干活&#xff0c;有一点指…

三个袋子

&#xff08;文章修改于2020年3月22日23点45分&#xff09; 第二次做这个原题时WA了两次&#xff0c;才发现是有些隐蔽的数据不能通过&#xff08;如32532525 99999&#xff09;为防止溢出&#xff0c;将所有的int型改为long long int型 时间限制: 1 Sec 内存限制: 128 MB [提交…

【转】手机怎么放可以减少辐射?

文章来源> http://health.huanqiu.com/hygiene/hint/2009-05/466422.html 随着无线通讯技术的发展&#xff0c;使用手机的人越来越多&#xff0c;而手机带来的相关健康问题也引起了人们更多的关注。手机的辐射到底对人体有多大危害&#xff0c;如何把危害的程度降到最低&a…

不要把自己装在袋子里面

这几天一直在处理疾控和卫生监督所网络的事情&#xff0c;感受如下&#xff1a; 1、不要把自己装在袋子里面。 2、不要把喜怒写在脸上。 3、低调是一种实用技巧。 4、有时候留白很重要。 呵呵&#xff0c;就这样吧。

Docker 将jar包 打包成容器,并挂载jar包和指定yml配置

1.在 Dockerfile 中指定基础镜像&#xff0c;如 openjdk:8-jdk-alpine。 2.在 Dockerfile 中创建一个工作目录&#xff0c;如 /app。 3.将 jar 包复制到工作目录中&#xff0c;可以使用 COPY 指令。 4.将 yml 配置文件复制到工作目录中&#xff0c;也可以使用 COPY 指令。 5.暴…

手机放哪里辐射危害最低?

一般来说&#xff0c;手机待机时辐射较小&#xff0c;通话时辐射大一些&#xff0c;而在手机号码已经拨出而尚未接通时&#xff0c;辐射最大&#xff0c;辐射量是待机时的3倍左右。这些辐射有可能改变人体组织&#xff0c;对人体健康造成不利影响。 别放枕头边 据中国室内装…

手机放法分析,放哪里最好?辐射小?

在家里、在办公室或在户外&#xff0c;我们都习惯把手机放在什么地方呢&#xff1f;放在口袋里、挂在腰间、放在枕头下担心会对不同部位造成辐射&#xff0c;影响身体健康&#xff0c;拿在手里、放在办公桌上担心被抢或遗失&#xff0c;放在包包里容易错失电话&#xff0c;到底…

闲置手机不要换锅换盆,你会后悔的

“女士们&#xff0c;先生们&#xff0c;你们好&#xff0c;不管是旧的、破的手机都可以换不锈钢脸盆”&#xff0c;这是街头回收旧手机的一条广告语。现在科技的发展越来越快&#xff0c;手机的更新换代也很快&#xff0c;相信朋友们家里的旧手机不下2&#xff0c;3部&#xf…