简体   繁体   English

默认的Maven tomcat插件在哪里配置?

[英]Where is the default Maven tomcat plugin configured?

In a Maven project I can use the tomcat plugin without adding it to the POM. 在Maven项目中,无需添加tomcat插件即可将其添加到POM中。 So I can deploy and run my webapp for example like this: 因此,我可以像这样部署和运行我的Web应用程序:

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? 我知道它正在使用一些默认配置,但是我的问题是,即使我没有配置它,为什么Maven仍允许我使用此插件? It also isn't in the super POM. 它也不在超级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 . 即使您没有在项目POM或settings.xml中配置任何内容,Maven也有一些约定。 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: 当您在命令行中以这种方式调用插件时,Maven尝试通过添加以下groupId之一来查找插件:

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

For the artifactId, it also tries to complete the "prefix" you specify (here tomcat ) with one of these: 对于artifactId,它还会尝试使用以下其中一项来完成您指定的“前缀”(此处为tomcat ):

  • maven-${prefix}-plugin : (convetion for official plugins) -> maven-tomcat-plugin maven-$ {prefix} -plugin :(官方插件的对流)-> maven-tomcat-plugin
  • ${prefix}-maven-plugin : (convention for 3rd party plugins) -> tomcat-maven-plugin $ {prefix} -maven-plugin :(第三方插件联盟)-> 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). 在您的特定情况下,默认值存在匹配项: org.codehaus.mojo:tomcat-maven-plugin:1.1 (或任何其他可用版本)。

A bit more detail here about the mechanics, and how you can also use these conventions for your own groupId's. 这里有一些机制的详细信息,以及如何将这些约定用于自己的groupId。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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