上面啟動start時,jdk1.9報錯,解決方法參考:https://blog.csdn.net/qq_33638719/article/details/83064664
訪問http://localhost:8081/nexus:
1 將項目發布到maven私服
1.1打開setting(在maven打開的)
在里面寫這個:
<!--配置用戶名密碼開始
--><server><id>releases
</id
><username>admin
</username
><password>admin123
</password
></server
><server><id>snapshots
</id
><username>admin
</username
><password>admin123
</password
></server
><!--配置用戶名密碼結束
--></servers
>
上面的id里面的值跟后面pom.xml對應就行,自定義的。
1.2配置pom.xml文件
我們隨機選一個項目試試發布就行:
<?xml version
="1.0" encoding
="UTF-8"?>
<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/xsd/maven-4.0.0.xsd"><parent><artifactId>maven_parent1
</artifactId
><groupId>cn
.itcast
</groupId
><version>1.0-SNAPSHOT
</version
><relativePath>../maven_parent1
/pom
.xml
</relativePath
></parent
><modelVersion>4.0.0</modelVersion
><artifactId>maven_son1
</artifactId
><!--添加到要上傳的項目pom中確定上傳路徑開始
--><distributionManagement><repository><id>releases
</id
><url>http
://localhost
:8081/nexus
/content
/repositories
/releases
/</url
></repository
><snapshotRepository><id>snapshots
</id
><url>http
://localhost
:8081/nexus
/content
/repositories
/snapshots
/</url
></snapshotRepository
></distributionManagement
><!--添加到要上傳的項目pom中確定上傳路徑結束
-->
</project
>
1.3執行deploy命令
執行成功:
這里也可以看得到:
雖然在maven寫release,但查release沒有包生成,因為發布到那個文件是看pom的這里的
2.從私服下載jar到本地倉庫
第一步:
在maven的setting.xml改:
<profile> <id>dev
</id> <repositories> <repository> <id>nexus
</id> <url>http://localhost:8081/nexus/content/groups/public/
</url> <releases> <enabled>true
</enabled> </releases> <snapshots> <enabled>true
</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>public
</id> <name>Public Repositories
</name> <url>http://localhost:8081/nexus/content/groups/public/
</url> </pluginRepository> </pluginRepositories> </profile>
第二步:
在maven的setting.xml激活模板:
(這里的dev只要和第一步的id對應就行)
<!--激活模板開始
--><activeProfiles><activeProfile>dev
</activeProfile
></activeProfiles
><!--激活模板結束
-->
打開自己的maven本地倉庫:
沒有1.2.12,現在我們從私服嚇到本地倉庫:
也是隨便打開一個項目的pom.xml導入:
然后本地倉庫就有了:
其實它是這樣的:
在idea的pom導入坐標,若本地沒有該坐標就向maven私服找,若私服沒有則從中央倉庫下載到私服。但有時候中央倉庫也沒有jar(如數據庫的驅動),那么就要我們將第三方jar安裝到本地倉庫和maven私服了。
私服從中央倉庫下的jar一般放在這:
也就是這:
3.將第三方jar安裝到本地倉庫和maven私服
3.1將第三方jar下到本地倉庫
出bug,還沒成功。
3.2 將第三方jar下到私服(一般在3rd party)
改maven的setting:
第三步:
打開jar所在目錄進入cmd管理員模式,輸入:
mvn deploy:deploy-file -Dfile=ojdbc14-10.2.0.4.0.jar -DgroupId=com.oracle -DartifactId=ojdbc14 – Dversion=10.2.0.4.0 -Dpackaging=jar – Durl=http://localhost:8081/nexus/content/repositories/thirdparty/ -DrepositoryId=thirdparty
也報錯了。。。
總結
以上是生活随笔為你收集整理的maven私服、将项目发布到maven私服、从私服下载jar到本地仓库、将第三方jar安装到本地仓库和maven私服的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。