Maven忽略單元測試及打包到Nexus的實現(xiàn)
我們的工程在打包發(fā)布時候,通常都需要忽略單元測試,以免因環(huán)境原因,無法通過單元測試而影響發(fā)布。Maven工程忽略單元測試有以下方法:
1、在Meven執(zhí)行命令后面增加參數(shù)
-Dmaven.test.skip=true ## 如: ## mvn install -Dmaven.test.skip=true -f pom.xml
2、在pom.xml文件中配置插件,忽略單元測試
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--忽略單元測試-->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
3、jar包手動install到本地
## 例如 有個jar包 xxx-test-4.1.0-SNAPSHOT.jar要install到本地 mvn install:install-file -DgroupId=org.xxx -DartifactId=xxx-test -Dversion=4.1.0-SNAPSHOT -Dpackaging=jar -Dfile=xxx-test-4.1.0-SNAPSHOT.jar
4、jar包手動deploy到Maven私服倉庫Nexus
1、配置環(huán)境變量
本機需要配置Maven環(huán)境變量:M2_HOME=D:\soft\apache-maven-3.8.2在Path中添加 %M2_HOME%\bin
2、配置nexus賬號密碼
在Maven的settings.xml中配置nexus賬號密碼
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
3、執(zhí)行命令:mvn deploy:deploy-file
參數(shù):
-DgroupId:組織名稱
-DartifactId:jar包名稱
-Dversion:版本號
-Dpackaging:文件類型
-Dfile:文件所在位置
-Dsources:源碼包
-Durl:Nexus地址
例如 有個jar包 alipay-sdk-java20171201160035.jar 要部署到nexus
mvn deploy:deploy-file -DgroupId=com.alipay -DartifactId=alipay-sdk -Dversion=java20171201160035 -Dpackaging=jar -Dfile=alipay-sdk-java20171201160035.jar -Dsources=alipay-sdk-java20171201160035-source.jar -Durl=http://xxx.xxx.xxx.xxx:8081/nexus/content/repositories/thirdparty -DrepositoryId=thirdparty
5、項目工程要deploy到nexus
如果是項目工程希望直接deploy到nexus中,在項目pom.xml中添加如下配置即可
<distributionManagement> <repository> <id>releases</id> <name>Nexus Release Repository</name> <url>http://nexus.xxxxxx.cn/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://nexus.xxxxxx.cn/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
到此這篇關(guān)于Maven忽略單元測試及打包到Nexus的實現(xiàn)的文章就介紹到這了,更多相關(guān)Maven忽略單元測試內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Springboot整合Swagger3全注解配置(springdoc-openapi-ui)
本文主要介紹了Springboot整合Swagger3全注解配置(springdoc-openapi-ui),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-03-03
Java ScheduledExecutorService定時任務案例講解
這篇文章主要介紹了Java ScheduledExecutorService定時任務案例講解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下2021-08-08
mybatis多個區(qū)間處理方式(雙foreach循環(huán))
這篇文章主要介紹了mybatis多個區(qū)間處理方式(雙foreach循環(huán)),具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-02-02
SpringMVC中ModelAndView用法小結(jié)
本文主要介紹了SpringMVC中ModelAndView用法小結(jié),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2023-12-12

