日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

maven 插件未找到_防止在多模块Maven中找到“未找到插件”

發布時間:2023/12/3 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 maven 插件未找到_防止在多模块Maven中找到“未找到插件” 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

maven 插件未找到

在多模塊Maven項目的子模塊上定義Maven插件會給我們一個“未找到插件”錯誤。 特別是如果我們有一個多模塊項目,并且只想在一個特定模塊中應用Maven插件,則此錯誤會經常發生。

假設我們有一個看起來像這樣的多模塊root pom。

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.jdriven.blog</groupId><artifactId>maven-plugin-multimodule</artifactId><version>0.1-SNAPSHOT</version><packaging>pom</packaging><modules><module>module1</module> <!-- Module1 is a regular jar --><module>module2</module> <!-- Module2 has tomcat7 plugin configured --></modules> </project>

本能地,我們將插件(例如tomcat7)添加到此特定模塊module2 ,就像這樣。

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><artifactId>maven-plugin-multimodule-module2</artifactId><packaging>war</packaging><parent><groupId>com.jdriven.blog</groupId><artifactId>maven-plugin-multimodule</artifactId><version>0.1-SNAPSHOT</version><relativePath>../</relativePath></parent><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration><!-- 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 xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.jdriven.blog</groupId><artifactId>maven-plugin-multimodule</artifactId><version>0.1-SNAPSHOT</version><packaging>pom</packaging><modules><module>module1</module> <!-- Module1 is a regular jar --><module>module2</module> <!-- Module2 has tomcat7 plugin configured --></modules><build><!-- In the multi-module root pom, use the pluginManagement to define the version of the maven-plugin --><pluginManagement><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version></plugin></plugins></pluginManagement></build></project>

并且在我們特定的模塊module2我們清除了插件的版本,因為它已在多模塊root pom(父代)中定義。

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><artifactId>maven-plugin-multimodule-module2</artifactId><packaging>war</packaging><parent><groupId>com.jdriven.blog</groupId><artifactId>maven-plugin-multimodule</artifactId><version>0.1-SNAPSHOT</version><relativePath>../</relativePath></parent><build><plugins><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-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

maven 插件未找到

總結

以上是生活随笔為你收集整理的maven 插件未找到_防止在多模块Maven中找到“未找到插件”的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。