maven私服搭建
Posted 魔有追求
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了maven私服搭建相关的知识,希望对你有一定的参考价值。
maven私服搭建
搭建私服的工具选择
Apache基金会的archiva
http://archiva.apache.org/
JFrog的Artifactory
https://jfrog.com/artifactory/
Sonatype的Nexus
https://my.sonatype.com/
这些都是开源的私服软件,都可以自由使用。用的最多的是第三种Nexus,本文我们主要以这个来讲解,其他2种有兴趣的朋友可以去研究一下。
Windows10中安装Nexus私服
nexus是java开发的,所以运行的时候需要有java环境的支持。
nexus下载和版本
https://www.sonatype.com/nexus-repository-oss
nexus-3.20.1-01-win64
C:Usersjie>java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
nexus启动
nexus.exe /run
D:chengxu
exus-3.20.1-01-win64
exus-3.20.1-01in>nexus.exe /run
2020-01-23 20:52:01,237+0800 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.pax.logging.NexusLogActivator - start
2020-01-23 20:52:03,362+0800 INFO [FelixStartLevel] *SYSTEM org.sonatype.nexus.features.internal.FeaturesWrapper - Fast FeaturesService starting
2020-01-23 20:56:54,923+0800 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer -
-------------------------------------------------
Started Sonatype Nexus OSS 3.20.1-01
-------------------------------------------------
浏览器访问
http://localhost:8081/
其他版本可能需要输入:http://localhost:8081/nexus
登录
需要修改密码
Your admin user password is located in
D:chengxu
exus-3.20.1-01-win64sonatype-work
exus3admin.password on the server.
修改启动端口
默认端口是8081,如果和本机有冲突,可以在下面的文件中修改:
${dir}etc
exus-default.properties
nexus仓库类型
上图中是nexus安装好默认自带的仓库列表,主要有3种类型:
代理仓库
宿主仓库
仓库组
下载组件
<server>
<id>maven_mozq</id>
<username>admin</username>
<password>admin</password>
</server>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.18</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>maven_mozq</id>
<url>http://localhost:8081/repository/maven-public/</url>
</repository>
</repositories>
D: 0 1>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven_mozq: http://localhost:8081/repository/maven-public/com/alibaba/druid/1.1.18/druid-1.1.18.jar
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/alibaba/druid/1.1.18/druid-1.1.18.jar
Downloaded from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/alibaba/druid/1.1.18/druid-1.1.18.jar (2.8 MB at 645 kB/s)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-01-provider ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D: 0 1srcmain
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo-01-provider ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35.810 s
[INFO] Finished at: 2020-01-23T22:41:29+08:00
[INFO] ------------------------------------------------------------------------
D: 0 1>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven_mozq: http://localhost:8081/repository/maven-public/com/alibaba/druid/1.1.18/druid-1.1.18.jar
Downloading from central: https://repo.maven.apache.org/maven2/com/alibaba/druid/1.1.18/druid-1.1.18.jar
Progress (1): 0.1/2.8 MB
D: 0 1>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven_mozq: http://localhost:8081/repository/maven-public/com/alibaba/druid/1.1.18/druid-1.1.18.jar
Downloaded from maven_mozq: http://localhost:8081/repository/maven-public/com/alibaba/druid/1.1.18/druid-1.1.18.jar (2.8 MB at 103 kB/s)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ demo-01-provider ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D: 0 1srcmain
esources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ demo-01-provider ---
[INFO] No sources to compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.263 s
[INFO] Finished at: 2020-01-23T22:57:20+08:00
[INFO] ------------------------------------------------------------------------
bugs
不能启动nexus
D:chengxu
exus-3.20.1-01-win64
exus-3.20.1-01in>nexus.exe
D:chengxu
exus-3.20.1-01-win64
exus-3.20.1-01in>nexus.exe /
D:chengxu
exus-3.20.1-01-win64
exus-3.20.1-01in>nexus.exe /start
Could not start service. Error code: 1060
方案:
nexus.exe /run
浏览器访问报404
D: 0 1>mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.mozq.dubbo:demo-01-provider >-------------------
[INFO] Building demo-01-provider 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from maven_mozq: http://localhost:8081/repository/maven-public/com/alibaba/druid/1.1.18/druid-1.1.18.pom
Downloading from alimaven: http://maven.aliyun.com/nexus/content/groups/public/com/alibaba/druid/1.1.18/druid-1.1.18.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.567 s
[INFO] Finished at: 2020-01-23T22:25:44+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project demo-01-provider: Could not resolve dependencies for project com.mozq.dubbo:demo-01-provider:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.alibaba:druid:jar:1.1.18: Failed to read artifact descriptor for com.alibaba:druid:jar:1.1.18: Could not transfer artifact com.alibaba:druid:pom:1.1.18 from/to alimaven (http://maven.aliyun.com/nexus/content/groups/public/): maven.aliyun.com: Unknown host maven.aliyun.com -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
ready to connect和manually blocked
需要在仓库中将Block相关的选项去除勾选。
1 Block outbound connections on the repository
2 Auto-block outbound connections on the repository if remote peer is detected as unreachable/unresponsive
等待连接状态不用管,使用的请求下载jar,就会自动变为remote available
以上是关于maven私服搭建的主要内容,如果未能解决你的问题,请参考以下文章