且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在MAVEN多模块项目中添加依赖关系的位置

更新时间:2022-12-13 10:59:57

您应该将Tomcat插件添加到Web项目中,因为它只能在类型为war的项目中工作。应该已经配置了一个jetty插件,所以mvn jetty:run应该从web文件夹工作。


I am trying to make sense of all the dependency thing in maven multiple module projects. As a starting point I used appfuse to create a new spring mvc multi-module project. It initially has web and core modules.

I found the knowledge of deploying this project. But when I get an error. I am confused of where to add a dependency or a plugin always. I would like to clarify with the following issue.

I created a appfuse mvc multimodule project. I maven installed the core and then maven jetty7:run on web (initially I ran mvn install on root folder and then I tied to mvn tomcat:run on the same folder. But it has to be done as below.

  • mvn install on core folder
  • mvn tomcat7:run on web folder

I initially got an error like missing prefix "Tomcat7". I resolved it by adding the following plugin to the pom in web.

       <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
        </plugin>

And that error was resolved. But I was unsure about that because I can add the plugin to the parent pom. Then I ran again mvn tomcat7:run on web file and now I am getting the following error.

[INFO] >>> tomcat7-maven-plugin:2.0:run (default-cli) @ test-web >>>
[WARNING] The POM for org.aspectj:aspectjweaver:jar:1.8.0.M1 is missing, no depe
ndency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

I am not sure where to add the dependency to which pom. I would like know some basics of how the poms can work together to do the installation. For example, There is also a parent pom. But I am not doing a mvn install or anything on the parent pom. I am going to the core and do a mvn install and then go to the web and do a mvn tomcat7:run

I this case how the parent pom contribute to the installation and ruining process? and how should I resolve the above warning and resolve the error.

Some informative answer is very much appreciated. Thanks

You should add the Tomcat plugin to the web project as it will only work in a project that's type "war". There should already be a jetty plugin configured, so "mvn jetty:run" should work from the web folder.