简体   繁体   中英

Where is the default Maven tomcat plugin configured?

In a Maven project I can use the tomcat plugin without adding it to the POM. So I can deploy and run my webapp for example like this:

mvn clean install tomcat:run

I know that it is using some default configuration, but my question is why Maven allows me to use this plugin even though I haven't configured it? It also isn't in the super POM. So I have no idea where it's configuration comes from. Does anyone know?

Maven has some conventions about it, even if you do not configure anything in the project POM or in your settings.xml . When you invoke a plugin that way in the command line, Maven tries to find the plugin by adding one of the following groupId's:

  • org.apache.maven.plugins
  • org.codehaus.mojo

For the artifactId, it also tries to complete the "prefix" you specify (here tomcat ) with one of these:

  • maven-${prefix}-plugin : (convetion for official plugins) -> maven-tomcat-plugin
  • ${prefix}-maven-plugin : (convention for 3rd party plugins) -> tomcat-maven-plugin

And for the version, it just tries to get the latest available.

In your particular case, there is a match for the defaults: org.codehaus.mojo:tomcat-maven-plugin:1.1 (or any other available version).

A bit more detail here about the mechanics, and how you can also use these conventions for your own groupId's.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM