Java maven反应堆构建学习实践

简介: Java maven反应堆构建学习实践

Java maven反应堆构建学习实践

实践环境

Apache Maven 3.0.5 (Red Hat 3.0.5-17)

应用示例

示例项目结构

maven示例项目组织结构如下

maven-study
│  pom.xml
├─first-sub-module
│  │  pom.xml
│  │
│  ├─src
│  │  ├─main
│  │  │  └─java
│  │  │      └─com
│  │  │          └─shouke
│  │  │              └─mvnstudy
│  │  │                      HelloMaven.java
│  │  │
│  │  └─test
│  │      └─java
│  │          └─com
│  │              └─shouke
│  │                  └─mvnstudy
│  │                          TestHelloMaven.java
│  │
│  └─sub-sub-module
│      │  pom.xml
│      │
│      └─src
│          ├─main
│          │  └─java
│          │      └─com
│          │          └─shouke
│          │              └─mvnstudy
│          │                      HelloMaven.java
│          │
│          └─test
│              └─java
│                  └─com
│                      └─shouke
│                          └─mvnstudy
│                                  TestHelloMaven.java
└─second-sub-module
    │  pom.xml
    └─src
        ├─main
        │  └─java
        │      └─com
        │          └─shouke
        │              └─mvnstudy
        │                      HelloMaven.java
        └─test
            └─java
                └─com
                    └─shouke
                        └─mvnstudy
                                TestHelloMaven.java

pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>parent-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <modules>    
        <module>first-sub-module</module>
        <module>second-sub-module</module>
    </modules>
</project>
</xml>

first-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>first-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.shouke.mvnstudy</groupId>
            <artifactId>second-sub-module</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.shouke.mvnstudy</groupId>
            <artifactId>sub-sub-module</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <parent>
        <groupId>com.shouke.mvnstudy</groupId>
        <!--父项目id-->
        <artifactId>parent-module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
</project>
</xml>

first-sub-module/sub-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>sub-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
</xml>

second-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>second-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <parent>
        <groupId>com.shouke.mvnstudy</groupId>
        <!--父项目id-->
        <artifactId>parent-module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
</project>
</xml>

学习实践

-pl选项应用

# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl first-sub-module  compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building first-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.219s
[INFO] Finished at: Fri Dec 24 11:20:23 CST 2021
[INFO] Final Memory: 17M/1447M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project first-sub-module: Could not resolve dependencies for project com.shouke.mvnstudy:first-sub-module:jar:1.0.0-SNAPSHOT: Could not find artifact com.shouke.mvnstudy:second-sub-module:jar:1.0.0-SNAPSHOT -> [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/DependencyResolutionException

-am选项应用

# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl first-sub-module -am compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] parent-module
[INFO] second-sub-module
[INFO] first-sub-module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building parent-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent-module ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building second-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ second-sub-module ---
[INFO] Deleting /root/maven-study/second-sub-module/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ second-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/second-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ second-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/second-sub-module/target/classes
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building first-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ first-sub-module ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ first-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/first-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ first-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/first-sub-module/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] parent-module ..................................... SUCCESS [0.146s]
[INFO] second-sub-module ................................. SUCCESS [0.576s]
[INFO] first-sub-module .................................. SUCCESS [0.346s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.187s
[INFO] Finished at: Fri Dec 24 11:22:06 CST 2021
[INFO] Final Memory: 22M/1096M
[INFO] ------------------------------------------------------------------------

-amd选项应用

对比示例

# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl second-sub-module compile
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building second-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ second-sub-module ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ second-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/second-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ second-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/second-sub-module/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.976s
[INFO] Finished at: Fri Dec 24 11:21:18 CST 2021
[INFO] Final Memory: 23M/1447M
[INFO] ------------------------------------------------------------------------
# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl second-sub-module -am compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] parent-module
[INFO] second-sub-module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building parent-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent-module ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building second-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ second-sub-module ---
[INFO] Deleting /root/maven-study/second-sub-module/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ second-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/second-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ second-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/second-sub-module/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] parent-module ..................................... SUCCESS [0.132s]
[INFO] second-sub-module ................................. SUCCESS [0.536s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.771s
[INFO] Finished at: Fri Dec 24 11:24:13 CST 2021
[INFO] Final Memory: 23M/1447M
[INFO] ------------------------------------------------------------------------

-amd应用示例

# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl second-sub-module -amd compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] second-sub-module
[INFO] first-sub-module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building second-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ second-sub-module ---
[INFO] Deleting /root/maven-study/second-sub-module/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ second-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/second-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ second-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/second-sub-module/target/classes
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building first-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ first-sub-module ---
[INFO] Deleting /root/maven-study/first-sub-module/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ first-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/first-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ first-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/first-sub-module/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] second-sub-module ................................. SUCCESS [0.652s]
[INFO] first-sub-module .................................. SUCCESS [0.344s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.100s
[INFO] Finished at: Fri Dec 24 11:24:33 CST 2021
[INFO] Final Memory: 24M/1157M
[INFO] ------------------------------------------------------------------------

嵌套子模块构建

# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl first-sub-module/sub-sub-module compile
[INFO] Scanning for projects...
[ERROR] Could not find the selected project in the reactor: first-sub-module/sub-sub-module -> [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/MavenExecutionException

修改first-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>first-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.shouke.mvnstudy</groupId>
            <artifactId>second-sub-module</artifactId>
            <version>1.0.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <parent>
        <groupId>com.shouke.mvnstudy</groupId>
        <!--父项目id-->
        <artifactId>parent-module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
    <modules>
        <module>sub-sub-module</module>
    </modules>
</project>
</xml>

修改first-sub-module/sub-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>sub-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <parent>
        <groupId>com.shouke.mvnstudy</groupId>
        <!--父项目id-->
        <artifactId>first-sub-module</artifactId>
        <version>1.0.0-SNAPSHOT</version>
    </parent>
</project>
</xml>
# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl first-sub-module/sub-sub-module -am compile
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] parent-module
[INFO] second-sub-module
[INFO] first-sub-module
[INFO] sub-sub-module
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building parent-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ parent-module ---
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building second-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ second-sub-module ---
[INFO] Deleting /root/maven-study/second-sub-module/target
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ second-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/second-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ second-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/second-sub-module/target/classes
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building first-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ first-sub-module ---
[INFO] Deleting /root/maven-study/first-sub-module/target
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building sub-sub-module 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ sub-sub-module ---
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ sub-sub-module ---
[debug] execute contextualize
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /root/maven-study/first-sub-module/sub-sub-module/src/main/resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ sub-sub-module ---
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /root/maven-study/first-sub-module/sub-sub-module/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] parent-module ..................................... SUCCESS [0.148s]
[INFO] second-sub-module ................................. SUCCESS [0.728s]
[INFO] first-sub-module .................................. SUCCESS [0.005s]
[INFO] sub-sub-module .................................... SUCCESS [0.370s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.370s
[INFO] Finished at: Fri Dec 24 11:39:07 CST 2021
[INFO] Final Memory: 22M/1098M
[INFO] ------------------------------------------------------------------------
结论

注意-pl只适用在“父子”结构的项目中,构建子项目

针对以上结论,修改相关pom.xml,再次测试验证

修改pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>parent-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
</xml>

修改second-sub-module/pom.xml

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.shouke.mvnstudy</groupId>
    <artifactId>second-sub-module</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <dependencies>
        <!-- junit 依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.10</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
</xml>
# mvn clean -Dautoconfig.skip=true -Dmaven.test.skip=true -pl second-sub-module compile
[INFO] Scanning for projects...
[ERROR] Could not find the selected project in the reactor: second-sub-module -> [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/MavenExecutionException

如上,提示找不到模块。

-------------------------------文字太少,占位符---------------------------------

-------------------------------文字太少,占位符---------------------------------

目录
相关文章
|
29天前
|
存储 监控 安全
单位网络监控软件:Java 技术驱动的高效网络监管体系构建
在数字化办公时代,构建基于Java技术的单位网络监控软件至关重要。该软件能精准监管单位网络活动,保障信息安全,提升工作效率。通过网络流量监测、访问控制及连接状态监控等模块,实现高效网络监管,确保网络稳定、安全、高效运行。
52 11
|
2月前
|
存储 缓存 安全
Java内存模型深度解析:从理论到实践####
【10月更文挑战第21天】 本文深入探讨了Java内存模型(JMM)的核心概念与底层机制,通过剖析其设计原理、内存可见性问题及其解决方案,结合具体代码示例,帮助读者构建对JMM的全面理解。不同于传统的摘要概述,我们将直接以故事化手法引入,让读者在轻松的情境中领略JMM的精髓。 ####
47 6
|
2月前
|
设计模式 Java 开发者
Java中的异常处理:理解与实践
【10月更文挑战第42天】在Java的世界中,异常处理是每个开发者必须面对的挑战。它就像是一场不可预知的风暴,可能会在任何时候突然降临,打乱我们的计划。但是,如果我们能够掌握正确的处理方法,这场风暴也可以变成推动我们前进的力量。本文将带你深入理解Java中的异常处理机制,通过代码示例,我们将一起学习如何捕获、处理和预防异常,让你的程序在面对任何挑战时都能保持稳健和优雅。
|
3天前
|
Kubernetes Java 持续交付
小团队 CI/CD 实践:无需运维,Java Web应用的自动化部署
本文介绍如何使用GitHub Actions和阿里云Kubernetes(ACK)实现Java Web应用的自动化部署。通过CI/CD流程,开发人员无需手动处理复杂的运维任务,从而提高效率并减少错误。文中详细讲解了Docker与Kubernetes的概念,并演示了从创建Kubernetes集群、配置容器镜像服务到设置GitHub仓库Secrets及编写GitHub Actions工作流的具体步骤。最终实现了代码提交后自动构建、推送镜像并部署到Kubernetes集群的功能。整个过程不仅简化了部署流程,还确保了应用在不同环境中的稳定运行。
31 9
|
2月前
|
Arthas 监控 Java
拥抱 OpenTelemetry:阿里云 Java Agent 演进实践
本文介绍了阿里云 Java Agent 4.x 版本在基于 OTel Java Agent 二次开发过程中的实践与思考,并重点从功能、性能、稳定性、兼容性四个方面介绍了所做的工作。同时也介绍了阿里云可观测团队积极参与开源建设取得的丰厚成果。
279 8
拥抱 OpenTelemetry:阿里云 Java Agent 演进实践
|
2月前
|
XML Java 测试技术
从零开始学 Maven:简化 Java 项目的构建与管理
Maven 是一个由 Apache 软件基金会开发的项目管理和构建自动化工具。它主要用在 Java 项目中,但也可以用于其他类型的项目。
70 1
从零开始学 Maven:简化 Java 项目的构建与管理
|
1月前
|
存储 监控 小程序
Java中的线程池优化实践####
本文深入探讨了Java中线程池的工作原理,分析了常见的线程池类型及其适用场景,并通过实际案例展示了如何根据应用需求进行线程池的优化配置。文章首先介绍了线程池的基本概念和核心参数,随后详细阐述了几种常见的线程池实现(如FixedThreadPool、CachedThreadPool、ScheduledThreadPool等)的特点及使用场景。接着,通过一个电商系统订单处理的实际案例,分析了线程池参数设置不当导致的性能问题,并提出了相应的优化策略。最终,总结了线程池优化的最佳实践,旨在帮助开发者更好地利用Java线程池提升应用性能和稳定性。 ####
|
1月前
|
安全 Java 数据库连接
Java中的异常处理:理解与实践
在Java的世界里,异常处理是维护代码健壮性的守门人。本文将带你深入理解Java的异常机制,通过直观的例子展示如何优雅地处理错误和异常。我们将从基本的try-catch结构出发,探索更复杂的finally块、自定义异常类以及throw关键字的使用。文章旨在通过深入浅出的方式,帮助你构建一个更加稳定和可靠的应用程序。
37 5
|
2月前
|
缓存 Java 开发者
Java多线程并发编程:同步机制与实践应用
本文深入探讨Java多线程中的同步机制,分析了多线程并发带来的数据不一致等问题,详细介绍了`synchronized`关键字、`ReentrantLock`显式锁及`ReentrantReadWriteLock`读写锁的应用,结合代码示例展示了如何有效解决竞态条件,提升程序性能与稳定性。
205 6
|
1月前
|
安全 Java 程序员
Java内存模型的深入理解与实践
本文旨在深入探讨Java内存模型(JMM)的核心概念,包括原子性、可见性和有序性,并通过实例代码分析这些特性在实际编程中的应用。我们将从理论到实践,逐步揭示JMM在多线程编程中的重要性和复杂性,帮助读者构建更加健壮的并发程序。