一:项目结构介绍
①:整体结构一个父pom,两个子pom
②:父pom
<?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.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.myrepository.mytemplate</groupId>
<artifactId>spring-family-mytemplate</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-family-mytemplate</name>
<description>所有项目模块管理</description>
<packaging>pom</packaging>
<properties>
<java.version>1.8</java.version>
</properties>
<modules>
<module>spring-family-common</module>
<module>spring-family-client</module>
</modules>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</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>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
③:family-common的pom
<?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.myrepository.mytemplate</groupId>
<artifactId>spring-family-mytemplate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.myrepository.mytemplate</groupId>
<artifactId>spring-family-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-family-common</name>
<description>项目中公用模块</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
④:family-client的pom
<?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.myrepository.mytemplate</groupId>
<artifactId>spring-family-mytemplate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.myrepository.mytemplate</groupId>
<artifactId>spring-family-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-family-client</name>
<description>Demo project for Spring Boot</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.myrepository.mytemplate</groupId>
<artifactId>spring-family-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
二:出错截图和分析
1:family-common打包未报错,family-client打包报错,因为client依赖于common工程,找不到common工程下对应的包和类,报错截图:
D:\localfile\jdk-8u172-windows-i586\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\ideaWork\spring-family-mytemplate -Dmaven.home=D:\localfile\apache-maven-3.5.4 -Dclassworlds.conf=D:\localfile\apache-maven-3.5.4\bin\m2.conf "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=64266:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath D:\localfile\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version2019.1.3 -s D:\localfile\apache-maven-3.5.4\conf\settings.xml -Dmaven.repo.local=D:\localfile\apache-maven-3.5.4\repository package
[INFO] Scanning for projects...
[INFO]
[INFO] ----------< com.myrepository.mytemplate:spring-family-client >----------
[INFO] Building spring-family-client 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-family-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-family-client ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to D:\ideaWork\spring-family-mytemplate\spring-family-client\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[3,41] 程序包com.myrepository.mytemplate.enums不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[4,45] 程序包com.myrepository.mytemplate.exception不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[5,42] 程序包com.myrepository.mytemplate.result不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[22,12] 找不到符号
符号: 类 PublicResult
位置: 类 com.myrepository.mytemplate.controller.HelloController
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.861 s
[INFO] Finished at: 2020-06-28T15:30:44+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project spring-family-client: Compilation failure: Compilation failure:
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[3,41] 程序包com.myrepository.mytemplate.enums不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[4,45] 程序包com.myrepository.mytemplate.exception不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[5,42] 程序包com.myrepository.mytemplate.result不存在
[ERROR] /D:/ideaWork/spring-family-mytemplate/spring-family-client/src/main/java/com/myrepository/mytemplate/controller/HelloController.java:[22,12] 找不到符号
[ERROR] 符号: 类 PublicResult
[ERROR] 位置: 类 com.myrepository.mytemplate.controller.HelloController
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Process finished with exit code 1
三:解决方式
①:在被依赖的工程pom中加上(configuration代表的意思是打包为可执行jar包)
<configuration>
<classifier>exec</classifier>
</configuration>
也就是在family-common工程中改为
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
</plugins>
</build>
②:再打包,继续报错
D:\localfile\jdk-8u172-windows-i586\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\ideaWork\spring-family-mytemplate -Dmaven.home=D:\localfile\apache-maven-3.5.4 -Dclassworlds.conf=D:\localfile\apache-maven-3.5.4\bin\m2.conf "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=65078:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath D:\localfile\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version2019.1.3 -s D:\localfile\apache-maven-3.5.4\conf\settings.xml -Dmaven.repo.local=D:\localfile\apache-maven-3.5.4\repository install
[INFO] Scanning for projects...
[INFO]
[INFO] ----------< com.myrepository.mytemplate:spring-family-client >----------
[INFO] Building spring-family-client 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-family-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-family-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-family-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\ideaWork\spring-family-mytemplate\spring-family-client\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-family-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ spring-family-client ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.myrepository.mytemplate.SpringFamilyClientApplicationTests
15:40:39.384 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
15:40:39.399 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
15:40:39.430 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
15:40:39.447 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests], using SpringBootContextLoader
15:40:39.451 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTests-context.xml] does not exist
15:40:39.452 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTestsContext.groovy] does not exist
15:40:39.452 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
15:40:39.453 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: SpringFamilyClientApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:40:39.505 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]
15:40:39.583 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [D:\ideaWork\spring-family-mytemplate\spring-family-client\target\classes\com\myrepository\mytemplate\SpringFamilyClientApplication.class]
15:40:39.584 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: URL [jar:file:/D:/localfile/apache-maven-3.5.4/repository/com/myrepository/mytemplate/spring-family-common/0.0.1-SNAPSHOT/spring-family-common-0.0.1-SNAPSHOT.jar!/com/myrepository/mytemplate/SpringFamilyCommonApplication.class]
15:40:39.587 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
15:40:39.587 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
15:40:39.588 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
15:40:39.588 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests], using SpringBootContextLoader
15:40:39.590 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTests-context.xml] does not exist
15:40:39.590 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTestsContext.groovy] does not exist
15:40:39.590 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
15:40:39.591 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: SpringFamilyClientApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:40:39.592 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]
15:40:39.596 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [D:\ideaWork\spring-family-mytemplate\spring-family-client\target\classes\com\myrepository\mytemplate\SpringFamilyClientApplication.class]
15:40:39.597 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: URL [jar:file:/D:/localfile/apache-maven-3.5.4/repository/com/myrepository/mytemplate/spring-family-common/0.0.1-SNAPSHOT/spring-family-common-0.0.1-SNAPSHOT.jar!/com/myrepository/mytemplate/SpringFamilyCommonApplication.class]
15:40:39.597 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
15:40:39.597 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)]
15:40:39.597 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
15:40:39.598 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests], using SpringBootContextLoader
15:40:39.598 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTests-context.xml] does not exist
15:40:39.598 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: class path resource [com/myrepository/mytemplate/SpringFamilyClientApplicationTestsContext.groovy] does not exist
15:40:39.599 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
15:40:39.599 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]: SpringFamilyClientApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:40:39.602 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.myrepository.mytemplate.SpringFamilyClientApplicationTests]
15:40:39.605 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [D:\ideaWork\spring-family-mytemplate\spring-family-client\target\classes\com\myrepository\mytemplate\SpringFamilyClientApplication.class]
15:40:39.606 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: URL [jar:file:/D:/localfile/apache-maven-3.5.4/repository/com/myrepository/mytemplate/spring-family-common/0.0.1-SNAPSHOT/spring-family-common-0.0.1-SNAPSHOT.jar!/com/myrepository/mytemplate/SpringFamilyCommonApplication.class]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.301 s <<< FAILURE! - in com.myrepository.mytemplate.SpringFamilyClientApplicationTests
[ERROR] com.myrepository.mytemplate.SpringFamilyClientApplicationTests Time elapsed: 0.3 s <<< ERROR!
java.lang.IllegalStateException: Found multiple @SpringBootConfiguration annotated classes [Generic bean: class [com.myrepository.mytemplate.SpringFamilyClientApplication]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [D:\ideaWork\spring-family-mytemplate\spring-family-client\target\classes\com\myrepository\mytemplate\SpringFamilyClientApplication.class], Generic bean: class [com.myrepository.mytemplate.SpringFamilyCommonApplication]; scope=; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in URL [jar:file:/D:/localfile/apache-maven-3.5.4/repository/com/myrepository/mytemplate/spring-family-common/0.0.1-SNAPSHOT/spring-family-common-0.0.1-SNAPSHOT.jar!/com/myrepository/mytemplate/SpringFamilyCommonApplication.class]]
[INFO]
[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR] SpringFamilyClientApplicationTests » IllegalState Found multiple @SpringBootCo...
[INFO]
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.331 s
[INFO] Finished at: 2020-06-28T15:40:40+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project spring-family-client: There are test failures.
[ERROR]
[ERROR] Please refer to D:\ideaWork\spring-family-mytemplate\spring-family-client\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
Process finished with exit code 1
③:解决方式:
在对应的子模块中加上
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
最终的结果就是family-common和family-client中都有如下代码:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
<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>
四:完美解决
D:\localfile\jdk-8u172-windows-i586\bin\java.exe -Dmaven.multiModuleProjectDirectory=D:\ideaWork\spring-family-mytemplate -Dmaven.home=D:\localfile\apache-maven-3.5.4 -Dclassworlds.conf=D:\localfile\apache-maven-3.5.4\bin\m2.conf "-javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=49844:D:\Program Files\JetBrains\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath D:\localfile\apache-maven-3.5.4\boot\plexus-classworlds-2.5.2.jar org.codehaus.classworlds.Launcher -Didea.version2019.1.3 -s D:\localfile\apache-maven-3.5.4\conf\settings.xml -Dmaven.repo.local=D:\localfile\apache-maven-3.5.4\repository install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] spring-family-mytemplate [pom]
[INFO] spring-family-common [jar]
[INFO] spring-family-client [jar]
[INFO]
[INFO] --------< com.myrepository.mytemplate:spring-family-mytemplate >--------
[INFO] Building spring-family-mytemplate 0.0.1-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.0.RELEASE:repackage (repackage) @ spring-family-mytemplate ---
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ spring-family-mytemplate ---
[INFO] Installing D:\ideaWork\spring-family-mytemplate\pom.xml to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-mytemplate\0.0.1-SNAPSHOT\spring-family-mytemplate-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ----------< com.myrepository.mytemplate:spring-family-common >----------
[INFO] Building spring-family-common 0.0.1-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-family-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-family-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-family-common ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\ideaWork\spring-family-mytemplate\spring-family-common\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-family-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ spring-family-common ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ spring-family-common ---
[INFO] Building jar: D:\ideaWork\spring-family-mytemplate\spring-family-common\target\spring-family-common-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.0.RELEASE:repackage (repackage) @ spring-family-common ---
[INFO] Attaching repackaged archive D:\ideaWork\spring-family-mytemplate\spring-family-common\target\spring-family-common-0.0.1-SNAPSHOT-exec.jar with classifier exec
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ spring-family-common ---
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-common\target\spring-family-common-0.0.1-SNAPSHOT.jar to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-common\0.0.1-SNAPSHOT\spring-family-common-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-common\pom.xml to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-common\0.0.1-SNAPSHOT\spring-family-common-0.0.1-SNAPSHOT.pom
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-common\target\spring-family-common-0.0.1-SNAPSHOT-exec.jar to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-common\0.0.1-SNAPSHOT\spring-family-common-0.0.1-SNAPSHOT-exec.jar
[INFO]
[INFO] ----------< com.myrepository.mytemplate:spring-family-client >----------
[INFO] Building spring-family-client 0.0.1-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ spring-family-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ spring-family-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ spring-family-client ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\ideaWork\spring-family-mytemplate\spring-family-client\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ spring-family-client ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ spring-family-client ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.2.0:jar (default-jar) @ spring-family-client ---
[INFO] Building jar: D:\ideaWork\spring-family-mytemplate\spring-family-client\target\spring-family-client-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.3.0.RELEASE:repackage (repackage) @ spring-family-client ---
[INFO] Attaching repackaged archive D:\ideaWork\spring-family-mytemplate\spring-family-client\target\spring-family-client-0.0.1-SNAPSHOT-exec.jar with classifier exec
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ spring-family-client ---
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-client\target\spring-family-client-0.0.1-SNAPSHOT.jar to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-client\0.0.1-SNAPSHOT\spring-family-client-0.0.1-SNAPSHOT.jar
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-client\pom.xml to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-client\0.0.1-SNAPSHOT\spring-family-client-0.0.1-SNAPSHOT.pom
[INFO] Installing D:\ideaWork\spring-family-mytemplate\spring-family-client\target\spring-family-client-0.0.1-SNAPSHOT-exec.jar to D:\localfile\apache-maven-3.5.4\repository\com\myrepository\mytemplate\spring-family-client\0.0.1-SNAPSHOT\spring-family-client-0.0.1-SNAPSHOT-exec.jar
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] spring-family-mytemplate 0.0.1-SNAPSHOT ............ SUCCESS [ 1.340 s]
[INFO] spring-family-common ............................... SUCCESS [ 1.351 s]
[INFO] spring-family-client 0.0.1-SNAPSHOT ................ SUCCESS [ 0.396 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.490 s
[INFO] Finished at: 2020-06-28T15:54:57+08:00
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0