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

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

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

maven 插件未找到

在多模塊Maven項(xiàng)目的子模塊上定義Maven插件會(huì)給我們一個(gè)“未找到插件”錯(cuò)誤。 特別是如果我們有一個(gè)多模塊項(xiàng)目,并且只想在一個(gè)特定模塊中應(yīng)用Maven插件,則此錯(cuò)誤會(huì)經(jīng)常發(fā)生。

假設(shè)我們有一個(gè)看起來(lái)像這樣的多模塊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上運(yùn)行命令mvn tomcat7:help時(shí),出現(xiàn)以下錯(cuò)誤:

[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

解決方案非常簡(jiǎn)單:我們?cè)诙嗄Kroot 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我們清除了插件的版本,因?yàn)樗言诙嗄Kroot 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>

現(xiàn)在,何時(shí)可以運(yùn)行命令mvn tomcat7:help ,不會(huì)出現(xiàn)任何錯(cuò)誤。 我們準(zhǔn)備在子模塊上配置插件。

翻譯自: https://www.javacodegeeks.com/2015/03/prevent-no-plugin-found-in-multi-module-maven.html

maven 插件未找到

總結(jié)

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

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。