我正在尝试为我们的团队建立一个私有(private)远程存储库。现在存储库提供以下服务,到目前为止我已经尝试过 -
现在我想做的是——
任何人都可以提出一些引用方法/或教程来满足上述两个目标吗?提前致谢。
编辑:我试过 Nathaniel Waisbrot的答案和 nexus-2.7.0-06-bundle。经过数小时的努力,我能够在使用 jre-7 时进行设置。使用 jre-6,无法启动 nexus。但是我们的项目是使用 JDK-6 部署的。我们不想更改当前
jre
版本。使用 jre-6
apache-archiva
没关系。但我不确定我是否可以实现上一节中的所有目标。有没有
archiva
用户/专家谁能告诉我我是否可以达到上一节中的这些目标?
请您参考如下方法:
我已设置 nexus
用于镜像我的 maven 本地存储库(位于 ~/.m2/repository.
)由于这篇文章仍然有很多人访问,我认为如果我分享我的配置方式对其他人会有所帮助 nexus
作为存储库管理员。这个程序完美运行对我来说 Ubuntu 12.04
.这里是 -
1. 下载 nexus-2.11.1-01-bundle.tar.gz或最新版本的nexus oss。
2. 提取主目录中的 tar 文件-
$ tar -xvf nexus-2.11.1-01-bundle.tar.gz
现在你会得到两个目录 -
nexus-2.11.1-01
和
sonatype-work
在您的主目录中。
3. 将这两个目录复制到
/usr/local/
目录(可以复制到其他地方) -
$ cp -r nexus-2.11.1-01 /usr/local/
$ cp -r sonatype-work /usr/local/
与nexus相关的可执行文件/配置文件存储在
nexus-2.11.1-01
pom.xml
中提到的目录和jar文件存储在
sonatype-work
目录。
这些 jar 文件是您的
~/.m2/repository
的镜像。 .第一次发出
mvn package
然后命令所有
jar
s 存储在这里。之后当你发出
mvn package
然后所有 jars 都是从 nexus 存储库下载的,而不是从中央存储库下载的。
4. 转至
/usr/local/
目录 -
$ cd /usr/local/
5. 创建指向
nexus-2.11.1-01
的链接-
$ sudo ln -s nexus-2.7.0-06 nexus
6. 现在运行 nexus 在终端中键入以下内容 -
$ bash nexus/bin/nexus console
这里 nexus 与您的控制台相连。如果您关闭控制台,则连接服务器将被终止。当您尝试为 Ubuntu 服务器机器运行 nexus 时,您可以使用 screen.
注:在尝试使用上述命令运行 nexus 时,可能会出现 2 个问题。如果您没有发现任何问题,请跳过接下来的 2 个步骤(步骤 - 7 和 8)
7. 由于权限不足,可能会出现第一个问题。阅读错误消息并采取必要的步骤。但作为 快速解决方案你可以这样做 -
$ sudo chmod -R 777 nexus-2.11.1-01/
$ sudo chmod -R 777 sonatype-work/
8. 如果您使用任何
jdk
低于 java 7 的版本可能会显示以下错误消息 -
wrapper | Launching a JVM... wrapper | JVM exited while loading the application. jvm 1 | Exception in thread "main" java.lang.UnsupportedClassVersionError: org/sonatype/nexus/bootstrap/jsw/JswLauncher : Unsupported major.minor version 51.0
在这种情况下,使用 jdk7 运行步骤 6 中提到的命令。在 ubuntu 中它非常简单。假设您有两个 jdk - jdk6 和 jdk7。您的项目在 jdk6 上运行。然后只有在运行 nexus 时,您才可以从终端执行此操作(假设您的 jdk7 在
/usr/lib/jvm/jdk1.7.0_45
目录中) -
$ export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_45
$ export PATH=$JAVA_HOME/bin:$PATH
9. 现在在浏览器中输入地址 - http://localhost:8081/nexus/ .如果步骤 1 到 6(如果发生错误,则步骤 1 到 8)完美完成,您可能会成功找到登录屏幕。默认登录用户名是 - 管理员 密码是 - 管理员123
10. 停止联系。只需关闭终端或按 Ctrl+C 在第 6 步的终端。在你
~/.m2
目录创建一个名为 -
settings.xml
的空文件.将以下内容复制到此
settings.xml
文件 -
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
11. 并将以下几行添加到项目的
pom.xml
中文件 -
<distributionManagement>
<snapshotRepository>
<id>my-snapshots</id>
<name>My internal repository</name>
<url>http://localhost:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>my-releases</id>
<name>My internal repository</name>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>