maven-assembly-plugin報紅無法加載報錯:Plugin?‘maven-assembly-plugin:‘?not?found
1.問題描述
maven pom.xml中maven-assembly-plugin報紅,無法加載

2.pom文件build構建部分詳解
<build>
<!--當項目沒有規(guī)定目標(Maven2 叫做階段)時的默認值-->
<defaultGoal>install</defaultGoal>
<!--build目標文件的存放目錄,默認在 ${basedir}/target 目錄-->
<directory>${basedir}/target</directory>
<finalName>${artifactId}-${version}</finalName>
<filters>
<filter>filters/filter1.properties</filter>
</filters>
<!--這個元素描述了項目相關的所有資源路徑列表,例如和項目相關的屬性文件,這些資源被包含在最終的打包文件里。-->
<resources>
<!--這個元素描述了項目相關或測試相關的所有資源路徑-->
<resource>
<!-- 描述了資源的目標路徑。該路徑相對target/classes目錄(例如${project.build.outputDirectory})。舉個例 子,如果你想資源在特定的包里( org.apache.maven.message,你就必須該元素設置為org/apache/maven /messages。然而,如果你只是想把資源放到源碼目錄結構里,就不需要該配置。-->
<targetPath/>
<!--是否使用參數(shù)值代替參數(shù)名。參數(shù)值取自properties元素或者文件里配置的屬性,文件在filters元素里列出。-->
<filtering/>
<!--描述存放資源的目錄,該路徑相對POM路徑-->
<directory/>
<!--包含的模式列表,例如**/*.xml.-->
<includes/>
<!--排除的模式列表,例如**/*.xml-->
<excludes/>
</resource>
</resources>
<!--這個元素描述了單元測試相關的所有資源路徑,例如和單元測試相關的屬性文件。-->
<testResources>
<!--這個元素描述了測試相關的所有資源路徑,參見build/resources/resource元素的說明-->
<testResource>
<targetPath/>
<filtering/>
<directory/>
<includes/>
<excludes/>
</testResource>
</testResources>
<!-- 在build時,執(zhí)行的插件,比較有用的部分,如使用jdk 8.0編譯等等-->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagBase>${git.conn}</tagBase>
<branchBase>${git.conn}</branchBase>
<username>${git.username}</username>
<password>${git.password}</password>
</configuration>
</plugin>
...
</plugins>
<!--子項目可以引用的默認插件信息。該插件配置項直到被引用時才會被解析或綁定到生命周期。給定插件的任何本地配置都會覆蓋這里的配置-->
<pluginManagement>
<plugins>
...
</plugins>
</pluginManagement>
</build>
</project>3.pom文件dependencies依賴部分詳解
依賴關系:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.0</version>
<type>jar</type>
<scope>test</scope>
<optional>true</optional>
</dependency>
...
</dependencies>groupId, artifactId, version:描述了依賴的項目唯一標志
可以通過以下方式進行安裝:
使用以下的命令安裝:
mvn install:install-file –Dfile=non-maven-proj.jar –DgroupId=some.group –DartifactId=non-maven-proj –Dversion=1創(chuàng)建自己的庫,并配置,使用deploy:deploy-file
設置此依賴范圍為system,定義一個系統(tǒng)路徑。不提倡。
- type:相應的依賴產品包形式,如jar,war
- scope:用于限制相應的依賴范圍,包括以下的幾種變量:
- compile :默認范圍,用于編譯
- provided:類似于編譯,但支持你期待jdk或者容器提供,類似于classpath
- runtime:在執(zhí)行時,需要使用
- test:用于test任務時使用
- system:需要外在提供相應得元素。通過systemPath來取得
- systemPath: 僅用于范圍為system。提供相應的路徑
- optional: 標注可選,當項目自身也是依賴時。用于連續(xù)依賴時使用獨占性外在告訴maven你只包括指定的項目,不包括相關的依賴。此因素主要用于解決版本沖突問題
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>2.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
</exclusion>
</exclusions>
</dependency>表示項目maven-embedder需要項目maven-core,但我們不想引用maven-core
4.pom文件其他標簽描述
- 繼承關系
- 一個強大的變化,maven帶來的是項目繼承。主要的設置:
- 定義父項目
<project> <modelVersion>4.0.0</modelVersion> <groupId>org.gene.demo</groupId> <artifactId>my-parent</artifactId> <version>2.0</version> <packaging>pom</packaging> </project>
packaging 類型,需要pom用于parent和合成多個項目。我們需要增加相應的值給父pom,用于子項目繼承。主要的元素如下:
- 依賴型
- 開發(fā)者和合作者
- 插件列表
- 報表列表
- 插件執(zhí)行使用相應的匹配ids
- 插件配置
- 子項目配置
<project>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.gene.demo</groupId>
<artifactId>my-parent</artifactId>
<version>2.0</version>
<relativePath>../my-parent</relativePath>
</parent>
<artifactId>my-project</artifactId>
</project>relativePath可以不需要,但是用于指明parent的目錄,用于快速查詢。
dependencyManagement:
用于父項目配置共同的依賴關系,主要配置依賴包相同因素,如版本,scope。
合成(或者多個模塊)
一個項目有多個模塊,也叫做多重模塊,或者合成項目。
如下的定義:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.gene.demo</groupId>
<artifactId>my-parent</artifactId>
<version>2.0</version>
<modules>
<module>my-project1</module>
<module>my-project2</module>
</modules>
</project>5.解決方案
由于,build中插件無法自動加載,在依賴中添加對應依賴更新后即可成功加載。
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>到此這篇關于maven-assembly-plugin報紅無法加載報錯:Plugin ‘maven-assembly-plugin:‘ not found的文章就介紹到這了,更多相關maven-assembly-plugin報紅內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
MyBatis中的SQL映射文件如何配置參數(shù)映射和使用方法
MyBatis 是一種開源的 Java 持久化框架,它可以自動將數(shù)據庫中的數(shù)據映射到 Java 對象中,并且使得 Java 對象可以非常方便地存儲到數(shù)據庫中,本文將介紹 MyBatis 中 SQL 映射文件的參數(shù)映射配置和使用方法,需要的朋友可以參考下2023-07-07
java中判斷字符串數(shù)組是否包含特定字符串的三種方法實現(xiàn)與對比
這篇文章主要為大家詳細介紹了java中判斷字符串數(shù)組是否包含特定字符串的三種方法實現(xiàn)與對比,文中的示例代碼講解詳細,感興趣的小伙伴可以了解下2025-12-12
JavaWeb開發(fā)之Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JC
這篇文章主要介紹了JavaWeb開發(fā)之Spring+SpringMVC+MyBatis+SpringSecurity+EhCache+JCaptcha 完整Web基礎框架的相關資料,需要的朋友可以參考下2016-12-12
Spring Security多賬號登錄的配置與實現(xiàn)方案
在現(xiàn)代企業(yè)應用和互聯(lián)網平臺中,用戶身份認證的需求日益復雜,傳統(tǒng)的單一用戶名密碼登錄方式已經無法滿足多樣化的業(yè)務場景,本文將深入探討如何基于 Spring Security 構建一個支持多賬號登錄的認證系統(tǒng),需要的朋友可以參考下2026-06-06
Mybatis單個參數(shù)的if判斷報異常There is no getter for property named ''x
今天小編就為大家分享一篇關于Mybatis單個參數(shù)的if判斷報異常There is no getter for property named 'xxx' in 'class java.lang.Integer'的解決方案,小編覺得內容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12
java_String和StringBuffer區(qū)別分析
JAVA平臺提供了兩個類:String和StringBuffer,它們可以儲存和操作字符串,即包含多個字符的字符數(shù)據。這個String類提供了數(shù)值不可改變的字符串。2013-04-04

