平时如果使用依赖或者继承的方式实现让项目A能够依赖到项目B,做法是先要将项目B安装install到本地仓库,然后项目A才能从本地仓库中依赖到相应的jar包。
但是还有一种做法不需要这样做,只需要在maven update父工程就可以按依赖的顺序将项目B,项目A依次安装到了本地,使得项目A直接就可以依赖项目B了,这种做法就是聚合。
聚合的使用:在一个总工程中配置聚合:(聚合的配置,只能配置在打包方式为pom的maven工程中)
配置信息如下:
<modules>
<module></module>
<module></module>
</modules>
创建父工程ParentMavenProject步骤如下:

其中pom.xml配置信息如下:
<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> <groupId>com.cai.demo</groupId> <artifactId>ParentMavenProject</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <description>总工程,packaging打包方式为pom,为的是能够使用聚合</description> <!-- 在父工程中配置聚合,避免前置工程的install操作,就是说:加入项目mavenProject2依赖于项目mavenProject2,如果 使用依赖的方式,则需要首先将项目mavenProject1安装install到本地仓库中才能供项目mavenProject2使用 --> <modules> <!-- 项目的根路径,就是从pom.xm文件所在的位置回到上一级那个路径, 这里写mavenProject1和mavenProject2的顺序跟安装到本地仓库的顺序无关,主要是看mavenProject1和mavenProject2中的pom.xml之间写的依赖关系
即如何在mavenProject2中写了dependy依赖于mavenProject1,则就会先安装mavenProject1,哪怕写<module>../mavenProject2在前面--> <module>../mavenProject1</module> <module>../mavenProject2</module> </modules> </project>
然后接下创建项目mavenProject1和mavenProject2,项目mavenProject2需要依赖项目mavenProject1
接着是执行package install就是先打包然后安装到本地仓库
一开始C:\Users\asuspc\.m2\repository本地仓库下是没有项目mavenProject1和mavenProject2的,

之后命令之后就会看到:
控制台信息如下:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] mavenProject1 [jar]
[INFO] mavenProject2 [jar]
[INFO] ParentMavenProject [pom]
[INFO]
[INFO] ----------------< com.caiguangbi.example:mavenProject1 >----------------
[INFO] Building mavenProject1 0.0.1-SNAPSHOT [1/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ mavenProject1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mavenProject1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ mavenProject1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ mavenProject1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ mavenProject1 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.demo.MavenProject1ApplicationTests
23:30:41.008 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.demo.MavenProject1ApplicationTests]
23:30:41.101 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
23:30:41.201 [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)]
23:30:41.330 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.demo.MavenProject1ApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
23:30:41.541 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.demo.MavenProject1ApplicationTests], using SpringBootContextLoader
23:30:41.588 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.MavenProject1ApplicationTests]: class path resource [com/example/demo/MavenProject1ApplicationTests-context.xml] does not exist
23:30:41.591 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.MavenProject1ApplicationTests]: class path resource [com/example/demo/MavenProject1ApplicationTestsContext.groovy] does not exist
23:30:41.592 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.demo.MavenProject1ApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
23:30:41.596 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.example.demo.MavenProject1ApplicationTests]: MavenProject1ApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
23:30:42.015 [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.example.demo.MavenProject1ApplicationTests]
23:30:42.553 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\target\classes\com\example\demo\MavenProject1Application.class]
23:30:42.561 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.example.demo.MavenProject1Application for test class com.example.demo.MavenProject1ApplicationTests
23:30:43.119 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.demo.MavenProject1ApplicationTests]: using defaults.
23:30:43.128 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
23:30:43.187 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
23:30:43.191 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
23:30:43.193 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
23:30:43.194 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@6e171cd7, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@402bba4f, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@795cd85e, org.springframework.test.context.support.DirtiesContextTestExecutionListener@59fd97a8, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@f5ac9e4, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@123ef382, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@dbf57b3, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@384ad17b, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@61862a7f]
23:30:43.287 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.290 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.297 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.298 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.303 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.305 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.321 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@1fa268de testClass = MavenProject1ApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@4f6ee6e4 testClass = MavenProject1ApplicationTests, locations = '{}', classes = '{class com.example.demo.MavenProject1Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@36b4cef0, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@37d31475, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5f3a4b84, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@612fc6eb], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
23:30:43.333 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.335 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject1ApplicationTests]
23:30:43.385 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@1fa268de testClass = MavenProject1ApplicationTests, testInstance = com.example.demo.MavenProject1ApplicationTests@37afeb11, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@4f6ee6e4 testClass = MavenProject1ApplicationTests, locations = '{}', classes = '{class com.example.demo.MavenProject1Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@36b4cef0, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@37d31475, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5f3a4b84, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@612fc6eb], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]].
23:30:44.080 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-14 23:30:46.573 INFO 11612 --- [ main] c.e.demo.MavenProject1ApplicationTests : Starting MavenProject1ApplicationTests on asuspc with PID 11612 (started by asuspc in E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1)
2019-04-14 23:30:46.588 INFO 11612 --- [ main] c.e.demo.MavenProject1ApplicationTests : No active profile set, falling back to default profiles: default
2019-04-14 23:30:49.658 INFO 11612 --- [ main] c.e.demo.MavenProject1ApplicationTests : Started MavenProject1ApplicationTests in 5.561 seconds (JVM running for 10.982)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 10.978 s - in com.example.demo.MavenProject1ApplicationTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ mavenProject1 ---
[INFO] Building jar: E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\target\mavenProject1-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ mavenProject1 ---
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/2.1.4.RELEASE/spring-boot-loader-tools-2.1.4.RELEASE.pom
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/2.1.4.RELEASE/spring-boot-loader-tools-2.1.4.RELEASE.pom (2.7 kB at 829 B/s)
[INFO] Downloading from : https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/2.1.4.RELEASE/spring-boot-loader-tools-2.1.4.RELEASE.jar
[INFO] Downloaded from : https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-loader-tools/2.1.4.RELEASE/spring-boot-loader-tools-2.1.4.RELEASE.jar (149 kB at 105 kB/s)
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ mavenProject1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mavenProject1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ mavenProject1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ mavenProject1 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ mavenProject1 ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ mavenProject1 ---
[INFO] Building jar: E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\target\mavenProject1-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ mavenProject1 ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mavenProject1 ---
[INFO] Installing E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\target\mavenProject1-0.0.1-SNAPSHOT.jar to C:\Users\asuspc\.m2\repository\com\caiguangbi\example\mavenProject1\0.0.1-SNAPSHOT\mavenProject1-0.0.1-SNAPSHOT.jar
[INFO] Installing E:\Spring Tools 4 for Eclipse\workSpace\mavenProject1\pom.xml to C:\Users\asuspc\.m2\repository\com\caiguangbi\example\mavenProject1\0.0.1-SNAPSHOT\mavenProject1-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ----------------< com.caiguangbi.example:mavenProject2 >----------------
[INFO] Building mavenProject2 0.0.1-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ mavenProject2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mavenProject2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\classes
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ mavenProject2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ mavenProject2 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ mavenProject2 ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.demo.MavenProject2ApplicationTests
23:31:07.389 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.example.demo.MavenProject2ApplicationTests]
23:31:07.421 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate]
23:31:07.490 [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)]
23:31:07.707 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.example.demo.MavenProject2ApplicationTests] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper]
23:31:07.810 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.example.demo.MavenProject2ApplicationTests], using SpringBootContextLoader
23:31:07.842 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.MavenProject2ApplicationTests]: class path resource [com/example/demo/MavenProject2ApplicationTests-context.xml] does not exist
23:31:07.862 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.example.demo.MavenProject2ApplicationTests]: class path resource [com/example/demo/MavenProject2ApplicationTestsContext.groovy] does not exist
23:31:07.881 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.example.demo.MavenProject2ApplicationTests]: no resource found for suffixes {-context.xml, Context.groovy}.
23:31:07.939 [main] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils - Could not detect default configuration classes for test class [com.example.demo.MavenProject2ApplicationTests]: MavenProject2ApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
23:31:08.348 [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.example.demo.MavenProject2ApplicationTests]
23:31:08.732 [main] DEBUG org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider - Identified candidate component class: file [E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\classes\com\example\demo\MavenProject2Application.class]
23:31:08.751 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Found @SpringBootConfiguration com.example.demo.MavenProject2Application for test class com.example.demo.MavenProject2ApplicationTests
23:31:09.213 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.example.demo.MavenProject2ApplicationTests]: using defaults.
23:31:09.217 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
23:31:09.257 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.web.ServletTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [javax/servlet/ServletContext]
23:31:09.273 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttributeSource]
23:31:09.309 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Skipping candidate TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] due to a missing dependency. Specify custom listener classes or make the default listener classes and their required dependencies available. Offending class: [org/springframework/transaction/interceptor/TransactionAttribute]
23:31:09.309 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@498d318c, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@6e171cd7, org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@402bba4f, org.springframework.test.context.support.DirtiesContextTestExecutionListener@795cd85e, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@59fd97a8, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@f5ac9e4, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@123ef382, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@dbf57b3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@384ad17b]
23:31:09.317 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.319 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.327 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.328 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.330 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.331 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.348 [main] DEBUG org.springframework.test.context.support.AbstractDirtiesContextTestExecutionListener - Before test class: context [DefaultTestContext@359f7cdf testClass = MavenProject2ApplicationTests, testInstance = [null], testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@1fa268de testClass = MavenProject2ApplicationTests, locations = '{}', classes = '{class com.example.demo.MavenProject2Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3d921e20, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@1a1d6a08, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5bcea91b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@eafc191], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]], class annotated with @DirtiesContext [false] with mode [null].
23:31:09.356 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.356 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.example.demo.MavenProject2ApplicationTests]
23:31:09.393 [main] DEBUG org.springframework.test.context.support.DependencyInjectionTestExecutionListener - Performing dependency injection for test context [[DefaultTestContext@359f7cdf testClass = MavenProject2ApplicationTests, testInstance = com.example.demo.MavenProject2ApplicationTests@52bf72b5, testMethod = [null], testException = [null], mergedContextConfiguration = [MergedContextConfiguration@1fa268de testClass = MavenProject2ApplicationTests, locations = '{}', classes = '{class com.example.demo.MavenProject2Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@3d921e20, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@1a1d6a08, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@5bcea91b, org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@0, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@eafc191], contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map[[empty]]]].
23:31:09.598 [main] DEBUG org.springframework.test.context.support.TestPropertySourceUtils - Adding inlined properties to environment: {spring.jmx.enabled=false, org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true, server.port=-1}
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.4.RELEASE)
2019-04-14 23:31:10.590 INFO 111384 --- [ main] c.e.demo.MavenProject2ApplicationTests : Starting MavenProject2ApplicationTests on asuspc with PID 111384 (started by asuspc in E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2)
2019-04-14 23:31:10.679 INFO 111384 --- [ main] c.e.demo.MavenProject2ApplicationTests : No active profile set, falling back to default profiles: default
2019-04-14 23:31:12.710 INFO 111384 --- [ main] c.e.demo.MavenProject2ApplicationTests : Started MavenProject2ApplicationTests in 3.104 seconds (JVM running for 7.151)
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.896 s - in com.example.demo.MavenProject2ApplicationTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ mavenProject2 ---
[INFO] Building jar: E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\mavenProject2-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ mavenProject2 ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ mavenProject2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ mavenProject2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ mavenProject2 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ mavenProject2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ mavenProject2 ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO]
[INFO] --- maven-jar-plugin:3.1.1:jar (default-jar) @ mavenProject2 ---
[INFO] Building jar: E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\mavenProject2-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.1.4.RELEASE:repackage (repackage) @ mavenProject2 ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ mavenProject2 ---
[INFO] Installing E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\target\mavenProject2-0.0.1-SNAPSHOT.jar to C:\Users\asuspc\.m2\repository\com\caiguangbi\example\mavenProject2\0.0.1-SNAPSHOT\mavenProject2-0.0.1-SNAPSHOT.jar
[INFO] Installing E:\Spring Tools 4 for Eclipse\workSpace\mavenProject2\pom.xml to C:\Users\asuspc\.m2\repository\com\caiguangbi\example\mavenProject2\0.0.1-SNAPSHOT\mavenProject2-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] ------------------< com.cai.demo:ParentMavenProject >-------------------
[INFO] Building ParentMavenProject 0.0.1-SNAPSHOT [3/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ ParentMavenProject ---
[INFO] Installing E:\Spring Tools 4 for Eclipse\workSpace\ParentMavenProject\pom.xml to C:\Users\asuspc\.m2\repository\com\cai\demo\ParentMavenProject\0.0.1-SNAPSHOT\ParentMavenProject-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] mavenProject1 ...................................... SUCCESS [ 43.107 s]
[INFO] mavenProject2 ...................................... SUCCESS [ 10.565 s]
[INFO] ParentMavenProject 0.0.1-SNAPSHOT .................. SUCCESS [ 0.479 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.381 s
[INFO] Finished at: 2019-04-14T23:31:15+08:00
执行成功之后就会在本地仓库中看到:

这样就聚合完成了。
浙公网安备 33010602011771号