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

如上,提示找不到模块。

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

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

目录
相关文章
|
11天前
|
设计模式 安全 Java
Java编程中的单例模式:理解与实践
【10月更文挑战第31天】在Java的世界里,单例模式是一种优雅的解决方案,它确保一个类只有一个实例,并提供一个全局访问点。本文将深入探讨单例模式的实现方式、使用场景及其优缺点,同时提供代码示例以加深理解。无论你是Java新手还是有经验的开发者,掌握单例模式都将是你技能库中的宝贵财富。
15 2
|
15天前
|
人工智能 前端开发 Java
基于开源框架Spring AI Alibaba快速构建Java应用
本文旨在帮助开发者快速掌握并应用 Spring AI Alibaba,提升基于 Java 的大模型应用开发效率和安全性。
基于开源框架Spring AI Alibaba快速构建Java应用
|
7天前
|
存储 安全 Java
Java多线程编程的艺术:从基础到实践####
本文深入探讨了Java多线程编程的核心概念、应用场景及其实现方式,旨在帮助开发者理解并掌握多线程编程的基本技能。文章首先概述了多线程的重要性和常见挑战,随后详细介绍了Java中创建和管理线程的两种主要方式:继承Thread类与实现Runnable接口。通过实例代码,本文展示了如何正确启动、运行及同步线程,以及如何处理线程间的通信与协作问题。最后,文章总结了多线程编程的最佳实践,为读者在实际项目中应用多线程技术提供了宝贵的参考。 ####
|
4天前
|
监控 安全 Java
Java中的多线程编程:从入门到实践####
本文将深入浅出地探讨Java多线程编程的核心概念、应用场景及实践技巧。不同于传统的摘要形式,本文将以一个简短的代码示例作为开篇,直接展示多线程的魅力,随后再详细解析其背后的原理与实现方式,旨在帮助读者快速理解并掌握Java多线程编程的基本技能。 ```java // 简单的多线程示例:创建两个线程,分别打印不同的消息 public class SimpleMultithreading { public static void main(String[] args) { Thread thread1 = new Thread(() -> System.out.prin
|
8天前
|
SQL Java 数据库连接
从理论到实践:Hibernate与JPA在Java项目中的实际应用
本文介绍了Java持久层框架Hibernate和JPA的基本概念及其在具体项目中的应用。通过一个在线书店系统的实例,展示了如何使用@Entity注解定义实体类、通过Spring Data JPA定义仓库接口、在服务层调用方法进行数据库操作,以及使用JPQL编写自定义查询和管理事务。这些技术不仅简化了数据库操作,还显著提升了开发效率。
20 3
|
7天前
|
Java UED
Java中的多线程编程基础与实践
【10月更文挑战第35天】在Java的世界中,多线程是提升应用性能和响应性的利器。本文将深入浅出地介绍如何在Java中创建和管理线程,以及如何利用同步机制确保数据一致性。我们将从简单的“Hello, World!”线程示例出发,逐步探索线程池的高效使用,并讨论常见的多线程问题。无论你是Java新手还是希望深化理解,这篇文章都将为你打开多线程的大门。
|
10天前
|
Java 大数据 API
14天Java基础学习——第1天:Java入门和环境搭建
本文介绍了Java的基础知识,包括Java的简介、历史和应用领域。详细讲解了如何安装JDK并配置环境变量,以及如何使用IntelliJ IDEA创建和运行Java项目。通过示例代码“HelloWorld.java”,展示了从编写到运行的全过程。适合初学者快速入门Java编程。
|
13天前
|
Java 程序员 数据库连接
Java中的异常处理:理解与实践
【10月更文挑战第29天】在Java编程的世界里,异常像是不请自来的客人,它们可能在任何时候闯入我们的程序宴会。了解如何妥善处理这些意外访客,不仅能够保持我们程序的优雅和稳健,还能确保它不会因为一个小小的失误而全盘崩溃。本文将通过浅显易懂的方式,带领读者深入异常处理的核心概念,并通过实际示例展现如何在Java代码中实现有效的异常管理策略。
|
16天前
|
Java 数据库连接 数据库
如何构建高效稳定的Java数据库连接池,涵盖连接池配置、并发控制和异常处理等方面
本文介绍了如何构建高效稳定的Java数据库连接池,涵盖连接池配置、并发控制和异常处理等方面。通过合理配置初始连接数、最大连接数和空闲连接超时时间,确保系统性能和稳定性。文章还探讨了同步阻塞、异步回调和信号量等并发控制策略,并提供了异常处理的最佳实践。最后,给出了一个简单的连接池示例代码,并推荐使用成熟的连接池框架(如HikariCP、C3P0)以简化开发。
35 2
|
17天前
|
缓存 Java 调度
Java中的多线程编程:从基础到实践
【10月更文挑战第24天】 本文旨在为读者提供一个关于Java多线程编程的全面指南。我们将从多线程的基本概念开始,逐步深入到Java中实现多线程的方法,包括继承Thread类、实现Runnable接口以及使用Executor框架。此外,我们还将探讨多线程编程中的常见问题和最佳实践,帮助读者在实际项目中更好地应用多线程技术。
22 3