Where to add dependencies in MAVEN multi-module pr

2019-08-04 09:23发布

问题:

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

回答1:

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.