我一直在努力理解默认生命周期的哪个阶段实际上将我的 pom.xml 中的远程依赖项拉到我的本地 .m2 文件夹中。
据我了解,mvn dependency:resolve
使用 Maven 依赖插件来获取任何所需的远程依赖项。根据此文档,它应该绑定到生成源阶段。
但是,如果我运行mvn generate-sources
,maven 似乎不会运行依赖项解析。
我想这是因为 Maven 依赖插件默认情况下不会运行,除非在我的 pom 中明确指定?
无论如何,如果我运行,我似乎只能点击此解析步骤,mvn compile
这显示我的远程依赖项在资源插件和编译器插件运行之前放置的某种前置步骤中被拉下来。
└[~/IdeaProjects/youtube-spring-reactive-programming]> mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ---------------< com.javatechie:springboot-webflux-demo >---------------
[INFO] Building springboot-webflux-demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.22/lombok-1.18.22.pom
Downloaded from central: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.22/lombok-1.18.22.pom (1.5 kB at 6.1 kB/s)
Downloading from central: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar
Downloaded from central: https://repo.maven.apache.org/maven2/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar (2.0 MB at 12 MB/s)
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ springboot-webflux-demo ---
[INFO] Copying 1 resource from src/main/resources to target/classes
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO]
[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ springboot-webflux-demo ---
[INFO] Changes detected - recompiling the module! :dependency
[INFO] Compiling 1 source file with javac [debug release 17] to target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.313 s
[INFO] Finished at: 2023-10-28T12:32:31-07:00
[INFO] ------------------------------------------------------------------------
如果我手动完成每个阶段,则在进入编译阶段之前我不会将远程依赖项拉下来:
validate
initialize
generate-sources
process-sources
generate-resources
process-resources
compile <--
我似乎找不到任何有关mvn compile
实际操作的详细文档。
问题:
启动依赖关系解析前置步骤的编译阶段有什么独特之处,该步骤似乎存在于阶段和更大的生命周期之外?