一、解决-Dmaven.multiModuleProjectDirectory system property is not set. Check $M2_HOME environment variable and mvn script match.
1.添加M2_HOME的环境变量
2.Preference->Java->Installed JREs->Edit 选择一个jdk,添加 -Dmaven.multiModuleProjectDirectory=$M2_HOME

二、解决:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.1.7.RELEASE:repackage (repackage) on project xuzj-common: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.1.7.RELEASE:repackage failed: Unable to find main class
Unable to find main class
在项目开发完成时,普通的
依赖模块报如上错误

经过百度后知道解决该问题:
1、首先确定该项目是不是spring-boot项目,如果是需要spring-boot-maven-plugin的打包配置
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这里引入了spring-boot-maven-plugin,打包时会去扫描项目main方法入口。
2、如果不是spring-boot项目,则不需要spring-boot-maven-plugin依赖,如果加上就会打包就会出现Unable to find main class。
3. 或者pom.xml中spring-boot-maven-plugin相关配置修改为普通的maven--plugin配置即可。

总结:我的项目common模块是各个模块都要引用的,所有这个打包不了,其他模块也包不了,
经过排查,我发现是我父类引用了spring-boot-maven-plugin依赖,而所有模块都继承了父类。
所以我的模块中还是有该插件,将父类中的该插件删除,我的common模块打包成功。

4、若springboot项目中没有加入spring-boot-maven-plugin 插件,则会启动失败

5、打包时他会将你写的Test类都执行一遍,为了打包不执行测试类可以让其不执行测试类
mvn clean package -Dmaven.test.skip=true
测试方法类:

在其idea中 Maven一栏中做如下配置:
