[英]Maven multi-module project and webapp project
I have two questions about maven project structure: 关于Maven项目结构,我有两个问题:
1) I am creating a maven multi-module project and would like to know if I can put all the common dependencies of the modules in the parent pom? 1)我正在创建一个Maven多模块项目,想知道是否可以将所有通用的模块依赖项放在父pom中? Is that the right way to do?
那是正确的方法吗?
2) If I am creating a maven webapp project that contains all web.xml and JSP files, where should the web controllers, listeners and model objects be residing? 2)如果我要创建一个包含所有web.xml和JSP文件的Maven Webapp项目,那么Web控制器,侦听器和模型对象应该放在哪里? In a separate maven jar project or in the same webapp project?
在单独的Maven Jar项目中还是在同一webapp项目中?
1) Read up on the difference between dependencyManagement
and dependencies
. 1)阅读
dependencyManagement
和dependencies
之间的区别。 Putting all common dependencies in the parent POM will work, but it's likely to cause spurious dependencies when you add a new module. 将所有常见的依赖项放到父POM中都可以,但是在添加新模块时可能会导致虚假的依赖项。
dependencyManagement
is recommended. 建议使用
dependencyManagement
。 You can specify all versions and exclusions in a central place, and then it's enough to specify groupId
and artifactId
for each dependency of each module. 您可以在一个中央位置指定所有版本和排除,然后为每个模块的每个依赖项指定
groupId
和artifactId
就足够了。
2) Java sources directly related to the web layer usually go into the war
module (unless you want to reuse them for a different project, then it's better to factor them out into a separate jar
). 2)与Web层直接相关的Java源代码通常会进入
war
模块(除非您想将它们重新用于其他项目,否则最好将它们分解到一个单独的jar
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.