mavne构建springboot多模块项目打包总出问题
1.先看项目结构:如图
公共模块,不是公告模块,上图写错了
2.1 先看父工程的pom.xml,重点看build中的插件
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <!-- jdk 1.8 编译--> <source>${java.version}</source> <target>${java.version}</target> <!-- 字符集utf-8--> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> </build>
2.2 common中的pom.xml 不用写build标签
2.3 clientModule中的pom.xml 的 build内容如下(clientModule需要打包,需要打包的都可以加入)
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.2.1.RELEASE</version> <!-- execution 重点一定要加 repackage--> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
3.打包client之前,先对parent 进行clean install
install 将所有子模块安装到maven仓库,也会把commonModule安装进去。
4.对clientModule进行 打包
这样就打包成功了,打包过程不报错,打包后运行不报错