【记录】Spring boot 父子级项目maven打jar包

  Spring boot 父子级项目maven打包

mvn clean ->表示运行清理操作(会默认吧target 文件夹中的数据清理)

mvn clean compile ->表示线运行清理后运行编译,会将代码编译到target文件夹中

mvn clean test -> 运行清理和测试

mvn clean package -> 运行清理和打包

mvn clean install -> 运行清理和安装,会将打好的包刀本地仓库中,以便其他项目可以调用

mvn clean deploy -> 运行清理和发布(发布到私服上面)

mvn archetype:generate -> 初始化生成maven项目骨架

  

错误一:Failed to execute goal on project xxx: Could not resolve dependencies for project 。。。

解决方案:在父项目下有的子项目在首次运行clean 和install前应该先运行父项目的clean和install

参考地址:https://blog.csdn.net/two_people/article/details/77883208

错误二:Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1 。。。

解决方案:spring-boot-maven-plugin,打包时会去扫描项目main方法入口,也就是说引入该配置,你就必须在项目src/main/java/下创建一个spring-boot启动类,

1. 添加spring-boot启动类。

2. 将pom.xml中的spring-boot-maven-plugin相关配置注释掉

3. pom.xml中spring-boot-maven-plugin相关配置修改为普通的maven--plugin配置即可。

参考地址:https://blog.csdn.net/qq_30553235/article/details/79094315

错误三:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.1.0:resources (default-resources) on project XXX: Cannot create resource output directory

解决方案:原因是target文件夹路径正在被XFTP占用,关掉就好了

在有spring boot main方法的pom中加入以下插件

如何给maven生成jar包重命名

因为我这个是父子级项目

所以只需要在每个子项目pom中定义生成名

pom.xml加入如下配置信息

 <properties>
 	<progectName>common-impl</progectName>
 	<maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> 
 </properties>
  <build>
  	<finalName>${progectName}-${maven.build.timestamp}</finalName>
  </build>

生成后jar包在target 上

  

原文地址:https://www.cnblogs.com/wbl001/p/12271698.html