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:相應的依賴產(chǎn)品包形式,如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報紅內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
詳解Springboot如何通過注解實現(xiàn)接口防刷
本文主要為大家介紹一種極簡潔、靈活通用接口防刷實現(xiàn)方式、通過在需要防刷的方法加上@Prevent?注解即可實現(xiàn)短信防刷,感興趣的可以了解一下2022-09-09
Spring系統(tǒng)屬性及spring.properties配置文件示例詳解
spring中有一個SpringProperties類,來保存spring的系統(tǒng)屬性,本文結合實例代碼對Spring系統(tǒng)屬性及spring.properties配置文件相關知識給大家介紹的非常詳細,需要的朋友參考下吧2023-07-07
SpringBoot基于Mybatis攔截器和JSqlParser實現(xiàn)數(shù)據(jù)隔離
本文將介紹如何在 Spring Boot 項目中利用Mybatis的強大攔截器機制結合JSqlParser,一個功能豐富的 SQL 解析器,來輕松實現(xiàn)數(shù)據(jù)隔離的目標,本文根據(jù)示例展示如何根據(jù)當前的運行環(huán)境來實現(xiàn)數(shù)據(jù)隔離,需要的朋友可以參考下2024-04-04

