江西住房和城乡建设网站,重庆市建设工程信息网登录入口,seo快速排名百度首页,汕头建站程序在多模块Maven项目的子模块上定义Maven插件会给我们“找不到插件”错误。 尤其是如果我们有一个多模块项目#xff0c;并且只想在一个特定模块中应用Maven插件#xff0c;则此错误会经常发生。 假设我们有一个看起来像这样的多模块root pom。 project xmlnshttp:… 在多模块Maven项目的子模块上定义Maven插件会给我们“找不到插件”错误。 尤其是如果我们有一个多模块项目并且只想在一个特定模块中应用Maven插件则此错误会经常发生。 假设我们有一个看起来像这样的多模块root pom。 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.jdriven.blog/groupIdartifactIdmaven-plugin-multimodule/artifactIdversion0.1-SNAPSHOT/versionpackagingpom/packagingmodulesmodulemodule1/module !-- Module1 is a regular jar --modulemodule2/module !-- Module2 has tomcat7 plugin configured --/modules
/project 本能地将插件例如tomcat7添加到此特定模块module2 就像这样。 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsdmodelVersion4.0.0/modelVersionartifactIdmaven-plugin-multimodule-module2/artifactIdpackagingwar/packagingparentgroupIdcom.jdriven.blog/groupIdartifactIdmaven-plugin-multimodule/artifactIdversion0.1-SNAPSHOT/versionrelativePath..//relativePath/parentbuildpluginsplugingroupIdorg.apache.tomcat.maven/groupIdartifactIdtomcat7-maven-plugin/artifactIdversion2.2/versionconfiguration!-- This is where our specific configuration goes --/configuration/plugin/plugins/build
/project 在多模块root pom上运行命令mvn tomcat7:help时出现以下错误 [ERROR] No plugin found for prefix tomcat7 in the current project
and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo]
available from the repositories 解决方案非常简单我们在多模块root pom的pluginManagement部分中指定插件。 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.jdriven.blog/groupIdartifactIdmaven-plugin-multimodule/artifactIdversion0.1-SNAPSHOT/versionpackagingpom/packagingmodulesmodulemodule1/module !-- Module1 is a regular jar --modulemodule2/module !-- Module2 has tomcat7 plugin configured --/modulesbuild!-- In the multi-module root pom, use the pluginManagement to define the version of the maven-plugin --pluginManagementpluginsplugingroupIdorg.apache.tomcat.maven/groupIdartifactIdtomcat7-maven-plugin/artifactIdversion2.2/version/plugin/plugins/pluginManagement/build/project 并且在我们特定的模块module2我们清除了插件的版本因为它已在多模块root pom父代中定义。 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsdmodelVersion4.0.0/modelVersionartifactIdmaven-plugin-multimodule-module2/artifactIdpackagingwar/packagingparentgroupIdcom.jdriven.blog/groupIdartifactIdmaven-plugin-multimodule/artifactIdversion0.1-SNAPSHOT/versionrelativePath..//relativePath/parentbuildpluginsplugingroupIdorg.apache.tomcat.maven/groupIdartifactIdtomcat7-maven-plugin/artifactId!-- No version needed here, it is already defined in the multi-module root pom --configuration!-- This is where our specific configuration goes --/configuration/plugin/plugins/build/project 现在何时可以运行命令mvn tomcat7:help而不会出现任何错误。 我们准备在子模块上配置插件。 翻译自: https://www.javacodegeeks.com/2015/03/prevent-no-plugin-found-in-multi-module-maven.html