`command “mvn spring-boot:run”在主模块以外的其他模块中运行时不能接受更改吗?`

huangapple go评论61阅读模式
英文:

command "mvn spring-boot:run" does not take changes at run in other modules than main module?

问题

以下是翻译好的内容:

我有一个多模块的Maven项目,配置如下:

子模块 Maven:modul-main:包含主类和带有application.properties文件的config文件夹
子模块 Maven:modul-common:另一个子模块

如果我在modul-main中更新代码,那么运行以下命令:

mvn spring-boot:run

会在运行时看到我的更改。
但是,如果我在modul-common中更新代码,那么运行以下命令:

mvn spring-boot:run

无法看到我的更改。

1)如何解释这个现象?(这个命令在后台执行了什么?)想要理解!
2)在这个命令行中是否有选项可以解决这个问题?

英文:

i have a multi-modules maven, which is configured like that :

  sub-module maven : modul-main : contains the Main class and config folder with an application.properties file
  sub-module maven : modul-common : an another sub-module 

if i update my code in modul-main, so the command

   mvn spring-boot:run 

see my changes at run
but IF i update my code in modul-common, so the command

   mvn spring-boot:run 

does not see my changes!

  1. how explain that ? (what the command does in background ?) want to understand !
  2. is there an option with this line command to solve this ?

答案1

得分: 2

这就是Maven的工作方式,与Spring Boot无关。当您在module-main中运行命令时,它只影响该模块,Maven不知道这个模块是一个更大项目的一部分,如果需要的话应该更新该项目。

当您在特定模块中时,依赖项是通过本地Maven存储库获取的(而不是每个模块的单独target/classes位置)。

与Gradle的工作方式相比,这是一个重要的区别(在模块中运行命令将自动更新兄弟模块,如果需要的话)。

英文:

That's how Maven works and this has nothing to do with Spring Boot. When you are in module-main and you run a command, it only impacts that module and Maven is not aware this module is part of a larger project that should be updated if necessary.

When you are in a particular module, dependencies are picked up via the local maven repository (not the individual target/classes locations for each module).

This is a significant difference compared to how Gradle works (running a command in a module is going to update sibling module automatically if needed).

huangapple
  • 本文由 发表于 2020年10月4日 20:37:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/64194692.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定