Resources:
中心仓库索引,好大的文件。
nexus-2.15.1-02-bundle.tar.gz openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz ?
Dockerfile:
FROM centos:centos7
MAINTAINER PCM
ADD openjdk-8u41-b04-linux-x64-14_jan_2020.tar.gz nexus-2.15.1-02-bundle.tar.gz /usr/local/
RUN sed -i 's/#RUN_AS_USER=/RUN_AS_USER=root/' /usr/local/nexus-2.15.1-02/bin/nexus
ENV JAVA_HOME=/usr/local/java-se-8u41-ri/ \
? ? PATH=$PATH:/usr/local/java-se-8u41-ri/bin
EXPOSE 8081
CMD /usr/local/nexus-2.15.1-02/bin/nexus start && tail -f /usr/local/nexus-2.15.1-02/logs/wrapper.log
?
docker run:
docker run --name=nexus -d -p8081:8081 -v /usr/local/sonatype-work/:/usr/local/sonatype-work/ --privileged=true ?549414168/nexus:v1
运行之后覆盖中心仓库索引,之后重启。
一直无法有索引和docker容器内权限有关系,真坑。
总算是配置成功。
相关资料:
nexus2下载:
Downloadhttps://help.sonatype.com/repomanager2/download#Download-NexusRepositoryManager2OSS索引地址:
Central Repository: .index
nexus-maven-repository-index.gz 2022-07-13 22:041615748068
nexus-maven-repository-index.gz.md5 2022-07-13 22:04 32
nexus-maven-repository-index.gz.sha1 2022-07-13 22:04 40
nexus-maven-repository-index.properties 2022-07-13 22:04 1130
解压索引工具:indexer-cli-5.1.1.jar
Maven Central Repository Search
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.properties
wget https://repo.maven.apache.org/maven2/org/apache/maven/indexer/indexer-cli/5.1.1/indexer-cli-5.1.1.jar
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz.md5
wget https://repo.maven.apache.org/maven2/.index/nexus-maven-repository-index.gz.sha1
?
导入本地仓库架包:
1.编脚本mavenimport.sh
#!/bin/bash
?
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params
while getopts ":r:u:p:" opt; do
?? ?case $opt in
?? ??? ?r) REPO_URL="$OPTARG"
?? ??? ?;;
?? ??? ?u) USERNAME="$OPTARG"
?? ??? ?;;
?? ??? ?p) PASSWORD="$OPTARG"
?? ??? ?;;
?? ?esac
done
?
find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
文件保存到仓库根路径。
2.启动脚本
./mavenimport.sh -u admin -p admin123 -r http://192.168.2.3:8081/nexus/content/repositories/myrep/
导入后项目测试
1.maven。setting设置
<localRepository>D:\apache-maven-3.6.0\test</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<!--profile 的 id-->
<id>dev</id>
<repositories>
<repository>
<!--仓库 id,repositories 可以配置多个仓库,保证 id 不重复-->
<id>nexus</id>
<!--仓库地址,即 nexus 仓库组的地址-->
<url>http://192.168.2.3:8081/nexus/content/groups/public/</url>
<!--是否下载 releases 构件-->
<releases>
<enabled>true</enabled>
</releases>
<!--是否下载 snapshots 构件-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!-- 插件仓库,maven 的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository>
<!-- 插件仓库的 id 不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://192.168.2.3:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
2.项目使用pom.xml
<build>
<plugins>
···
<!--这部分是之前已有,顺便贴上了-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
</configuration>
</plugin>
<plugin>
<!-- skip maven test -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<!--这部分是之前已有,顺便贴上了-->
······
<!--这部分是重点,没有发布不到nexus私服仓库-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>releases</id>
<url>http://192.168.2.3:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.2.3:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
温馨提示:
此处注意:pom中的这部分新增URL和ID与setting中的对应。
不新增这部分也可以使用。
|