设置本地Nexus存储库并从Maven部署WAR文件
Maven Central充当中央存储库管理器,其中二进制工件由不同的团队/公司/个人上载并与世界其他地方共享。 就像github和其他对源代码控制非常有效的源代码存储库一样,这些存储库管理器还充当您自己生成的二进制工件的部署目标。
设置本地存储库管理器具有多个优点。 最主要的是,它们充当Maven Central之间的高度可配置代理,因此每个人都不必从中央存储库下载所有依赖项。 另一个主要原因是要控制团队内部临时生成的工件。 使用存储库管理器的原因详细说明了完整的好处。
本技术提示将展示如何设置本地Nexus信息库管理器,以及将工件(快照和发行版)推送到其中。
让我们开始吧!
安装和配置本地Nexus存储库
- 下载并解压缩最新的Nexus OSS 。 默认管理员的登录名/密码是admin / admin123。 默认的部署登录名/密码是Deployment / deployment123。
- 以以下方式启动Nexus:
nexus-2.11.2-03> ./bin/nexus start Starting Nexus OSS... Started Nexus OSS.
日志可以看成是:
nexus-2.11.2-03> tail -f logs/wrapper.log
或者,您可以从控制台本身中显示日志的位置开始:
nexus-2.11.2-03> ./bin/nexus console Running Nexus OSS... wrapper | --> Wrapper Started as Console wrapper | Launching a JVM... jvm 1 | Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=192m; support was removed in 8.0 jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org jvm 1 | Copyright 1999-2006 Tanuki Software, Inc. All Rights Reserved. jvm 1 | . . .jvm 1 | 2015-02-24 00:17:28,706-0800 INFO [jetty-main-1] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Running jvm 1 | 2015-02-24 00:17:28,706-0800 INFO [WrapperListener_start_runner] *SYSTEM org.sonatype.nexus.bootstrap.jetty.JettyServer - Started jvm 1 | 2015-02-24 00:17:30,713-0800 INFO [ar-4-thread-3] *SYSTEM org.sonatype.nexus.proxy.maven.routing.internal.ManagerImpl - Updated and published prefix file of "Public Repositories" [id=public]
- 将Maven设置文件(〜.m2 / settings.xml)配置为包括以下默认部署用户名和密码:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"><servers><server><id>deployment</id><username>deployment</username><password>deployment123</password></server></servers> </settings>
将快照部署到本地Nexus存储库
- 从github.com/javaee-samples/javaee7-simple-sample签出一个简单的Java EE示例。
- 通过以下方式创建WAR文件并将其部署到本地Nexus存储库中:
javaee7-simple-sample> mvn deploy [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building javaee7-simple-sample 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javaee7-simple-sample --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaee7-simple-sample --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 4 source files to /Users/arungupta/workspaces/javaee7-simple-sample/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javaee7-simple-sample --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/arungupta/workspaces/javaee7-simple-sample/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javaee7-simple-sample --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javaee7-simple-sample --- [INFO] No tests to run. [INFO] [INFO] --- maven-war-plugin:2.3:war (default-war) @ javaee7-simple-sample --- [INFO] Packaging webapp [INFO] Assembling webapp [javaee7-simple-sample] in [/Users/arungupta/workspaces/javaee7-simple-sample/target/javaee7-simple-sample] [INFO] Processing war project [INFO] Copying webapp resources [/Users/arungupta/workspaces/javaee7-simple-sample/src/main/webapp] [INFO] Webapp assembled in [33 msecs] [INFO] Building war: /Users/arungupta/workspaces/javaee7-simple-sample/target/javaee7-simple-sample.war [INFO] [INFO] --- maven-install-plugin:2.4:install (default-install) @ javaee7-simple-sample --- [INFO] Installing /Users/arungupta/workspaces/javaee7-simple-sample/target/javaee7-simple-sample.war to /Users/arungupta/.m2/repository/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-SNAPSHOT.war [INFO] Installing /Users/arungupta/workspaces/javaee7-simple-sample/pom.xml to /Users/arungupta/.m2/repository/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-SNAPSHOT.pom [INFO] [INFO] >>> wildfly-maven-plugin:1.0.2.Final:deploy (default) > package @ javaee7-simple-sample >>> [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ javaee7-simple-sample --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ javaee7-simple-sample --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ javaee7-simple-sample --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/arungupta/workspaces/javaee7-simple-sample/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ javaee7-simple-sample --- [INFO] No sources to compile [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ javaee7-simple-sample --- [INFO] No tests to run. [INFO] Skipping execution of surefire because it has already been run for this configuration [INFO] [INFO] --- maven-war-plugin:2.3:war (default-war) @ javaee7-simple-sample --- [INFO] Packaging webapp [INFO] Assembling webapp [javaee7-simple-sample] in [/Users/arungupta/workspaces/javaee7-simple-sample/target/javaee7-simple-sample] [INFO] Processing war project [INFO] Copying webapp resources [/Users/arungupta/workspaces/javaee7-simple-sample/src/main/webapp] [INFO] Webapp assembled in [3 msecs] [INFO] Building war: /Users/arungupta/workspaces/javaee7-simple-sample/target/javaee7-simple-sample.war [INFO] [INFO] <<< wildfly-maven-plugin:1.0.2.Final:deploy (default) < package @ javaee7-simple-sample <<< [INFO] [INFO] --- wildfly-maven-plugin:1.0.2.Final:deploy (default) @ javaee7-simple-sample --- Feb 24, 2015 1:02:46 AM org.xnio.Xnio <clinit> INFO: XNIO version 3.2.2.Final Feb 24, 2015 1:02:46 AM org.xnio.nio.NioXnio <clinit> INFO: XNIO NIO Implementation Version 3.2.2.Final Feb 24, 2015 1:02:46 AM org.jboss.remoting3.EndpointImpl <clinit> INFO: JBoss Remoting version 4.0.3.Final [INFO] [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ javaee7-simple-sample --- Downloading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/maven-metadata.xml Downloaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/maven-metadata.xml (783 B at 4.0 KB/sec) Uploading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-20150224.090247-2.war Uploaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-20150224.090247-2.war (6 KB at 90.4 KB/sec) Uploading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-20150224.090247-2.pom Uploaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/javaee7-simple-sample-1.0-20150224.090247-2.pom (3 KB at 53.2 KB/sec) Downloading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/maven-metadata.xml Downloaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/maven-metadata.xml (297 B at 13.8 KB/sec) Uploading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/maven-metadata.xml Uploaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/1.0-SNAPSHOT/maven-metadata.xml (783 B at 20.7 KB/sec) Uploading: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/maven-metadata.xml Uploaded: http://localhost:8081/nexus/content/repositories/snapshots/org/javaee7/sample/javaee7-simple-sample/maven-metadata.xml (297 B at 6.7 KB/sec) [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.398 s [INFO] Finished at: 2015-02-24T01:02:47-08:00 [INFO] Final Memory: 22M/310M [INFO] ------------------------------------------------------------------------
快照存储库经过几次构建后,可以在localhost:8081 / nexus /#view-repositories; snapshots〜browsestorage中看到,如下所示:
实际的存储库存储在
../sonatype-work/nexus
目录中。 这是在解压缩Nexus OSS捆绑包的同时创建的。
将发行版部署到本地Nexus存储库
- 清除任何以前执行的发行版:
javaee7-simple-sample> mvn release:clean -P release [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building javaee7-simple-sample 1.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.5.1:clean (default-cli) @ javaee7-simple-sample --- [INFO] Cleaning up after release... [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.912 s [INFO] Finished at: 2015-02-24T02:18:53-08:00 [INFO] Final Memory: 10M/245M [INFO] ------------------------------------------------------------------------
- 准备下一个版本:
javaee7-simple-sample> mvn release:prepare -P release [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building javaee7-simple-sample 1.3-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-release-plugin:2.5.1:prepare (default-cli) @ javaee7-simple-sample --- [INFO] Verifying that there are no local modifications... [INFO] ignoring changes on: **/pom.xml.releaseBackup, **/pom.xml.next, **/pom.xml.tag, **/pom.xml.branch, **/release.properties, **/pom.xml.backup [INFO] Executing: /bin/sh -c cd /Users/arungupta/workspaces/javaee7-simple-sample && git rev-parse --show-toplevel [INFO] Working directory: /Users/arungupta/workspaces/javaee7-simple-sample [INFO] Executing: /bin/sh -c cd /Users/arungupta/workspaces/javaee7-simple-sample && git status --porcelain . [INFO] Working directory: /Users/arungupta/workspaces/javaee7-simple-sample [WARNING] Ignoring unrecognized line: ?? release.properties [INFO] Checking dependencies and plugins for snapshots ... What is the release version for "javaee7-simple-sample"? (org.javaee7.sample:javaee7-simple-sample) 1.3: : What is SCM release tag or label for "javaee7-simple-sample"? (org.javaee7.sample:javaee7-simple-sample) v1.3: : What is the new development version for "javaee7-simple-sample"? (org.javaee7.sample:javaee7-simple-sample) 1.4-SNAPSHOT: : [INFO] Transforming 'javaee7-simple-sample'... [INFO] Not generating release POMs [INFO] Executing goals 'clean verify'... [WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance. [INFO] [INFO] Scanning for projects... [INFO] [INFO] [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Building javaee7-simple-sample 1.3 [INFO] [INFO] ------------------------------------------------------------------------. . .[INFO] Executing: /bin/sh -c cd /Users/arungupta/workspaces/javaee7-simple-sample && git symbolic-ref HEAD [INFO] Working directory: /Users/arungupta/workspaces/javaee7-simple-sample [INFO] Executing: /bin/sh -c cd /Users/arungupta/workspaces/javaee7-simple-sample && git push https://github.com/javaee-samples/javaee7-simple-sample.git refs/heads/master:refs/heads/master [INFO] Working directory: /Users/arungupta/workspaces/javaee7-simple-sample [INFO] Release preparation complete. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:04 min [INFO] Finished at: 2015-02-24T02:55:59-08:00 [INFO] Final Memory: 11M/245M [INFO] ------------------------------------------------------------------------
- 执行发布:
javaee7-simple-sample> mvn javadoc:jar source:jar release:perform -P release [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building javaee7-simple-sample 1.4-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-javadoc-plugin:2.10.1:jar (default-cli) @ javaee7-simple-sample ---. . .[INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] BUILD FAILURE [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [INFO] Total time: 5.820 s [INFO] [INFO] Finished at: 2015-02-24T02:58:16-08:00 [INFO] [INFO] Final Memory: 31M/312M [INFO] [INFO] ------------------------------------------------------------------------ [INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project javaee7-simple-sample: Failed to deploy artifacts: Could not transfer artifact org.javaee7.sample:javaee7-simple-sample:war:1.3 from/to deployment (http://localhost:8081/nexus/content/repositories/releases/): Failed to transfer file: http://localhost:8081/nexus/content/repositories/releases/org/javaee7/sample/javaee7-simple-sample/1.3/javaee7-simple-sample-1.3.war. Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]
注意,该命令以错误结尾。 这类似于此处报告的内容,但奇怪的是文件仍在Nexus上载。 这是来自localhost:8081 / nexus /#view-repositories; releases〜browsestorage的快照,同时尝试测试多个版本并想知道这些“虚假”错误消息:
该错误将需要更多的调试,但现在至少可以将快照和发行版本存储在本地Nexus存储库中。
更新: Manfred Moser通过发送拉取请求帮助调试了该错误。 现在,此错误已消失,而应显示类似以下内容:
[INFO] Uploaded: http://localhost:8081/nexus/content/repositories/releases/org/javaee7/sample/javaee7-simple-sample/1.8/javaee7-simple-sample-1.8-sources.jar (3 KB at 74.7 KB/sec)
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD SUCCESS
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 5.673 s
[INFO] [INFO] Finished at: 2015-02-26T03:50:18+05:30
[INFO] [INFO] Final Memory: 31M/320M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] Cleaning up after release...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:10 min
[INFO] Finished at: 2015-02-26T03:50:30+05:30
[INFO] Final Memory: 13M/245M
[INFO] ------------------------------------------------------------------------
您学习了如何设置本地Nexus Repository并向其推送快照和发布版本。 随后的博客将展示如何将此存储库用于CI / CD。
请享用!
翻译自: https://www.javacodegeeks.com/2015/03/setup-local-nexus-repository-and-deploying-war-file-from-maven.html
设置本地Nexus存储库并从Maven部署WAR文件相关推荐
- maven 部署nexus_设置本地Nexus存储库并从Maven部署WAR文件
maven 部署nexus Maven Central充当中央存储库管理器,二进制文件由不同的团队/公司/个人上载并与世界其他地方共享. 就像github和其他对源代码控制非常有效的源代码存储库一样, ...
- git idea 本地历史版本回滚_如何为IDEA项目创建GitHub存储库和本地Git存储库
有几种方法可以使用IntelliJ IDEA来发布我们在GitHub上编写的代码.在此博客中,我们将介绍两种方法.第一个步骤是最快的一步,您可以在其中创建本地和远程存储库.第二种方法是多步骤,当您要为 ...
- 2020.2idea怎么创建html项目_如何为IDEA项目创建GitHub存储库和本地Git存储库
有几种方法可以使用IntelliJ IDEA来发布我们在GitHub上编写的代码.在此博客中,我们将介绍两种方法.第一个步骤是最快的一步,您可以在其中创建本地和远程存储库.第二种方法是多步骤,当您要为 ...
- linux8怎么搭建本地yum仓库,CentOS8 创建本地YUM存储库
原标题:CentOS8 创建本地YUM存储库 本文针对CentOS8中的新功能yum做简要介绍和配置,在 CentOS8中分为两个存储库: BaseOS 应用程序流(AppStream) BaseOS ...
- 如何仅从git存储库中稀疏签出单个文件?
如何从git仓库中检出一个文件? #1楼 git checkout branch_or_version-路径/文件 示例: git checkout HEAD -- main.c #2楼 如果您已经有 ...
- (转)用 Maven 部署 war 包到远程 Tomcat 服务器
转自蒋国纲 www.cnblogs.com/guogangj/p/5505228.html 用Maven部署war包到远程Tomcat服务器 过去我们发布一个Java Web程序通常的做法就是把它打成 ...
- nexus 安装_Jenkins Pipelines将制品发布到Nexus存储库
在本指南中,我们将使用Jenkins作为持续集成服务器,并使用Nexus Repository 作为构建存储库. 本指南的目的是创建一个工作流,我们可以在该工作流中通过Maven和CI服务器来构建,存 ...
- 如何确定最初克隆本地Git存储库的URL?
几天前我从GitHub上撤了一个项目. 我已经发现GitHub上有几个叉子,我忽略了我最初采用的那个. 如何确定我拉出的哪个叉子? #1楼 打印任意命名的远程提取URL: git remote -v ...
- 本地git存储库关闭_Git 入门:术语基础 | Linux 中国
想学习 Git?看看这个最重要的术语和命令的快速总结. • 来源:linux.cn • 作者:Matthew Broberg • 译者:Xingyu.Wang • (本文字数:4793,阅读时长大约: ...
最新文章
- 关于学习Python的一点学习总结(58->匹配对象和编组)
- 如何解决编译linux内核(解决声卡问题),遭遇fatal error: linux/limits.h: 没有那个文件或目录
- 面试题16: 数值的整数次方
- java中实现十六进制和十进制之间的转换
- 2017年,Java程序猿10本经典好书推荐
- 巴塞尔大学合作项目博士招生,医学图像分析领域
- 游戏安全报告(2017 - 2018全年)
- jquery选择器之基本选择器
- linux查看文件标签,linux下不解包查看tar包文件内容
- 转载:洛克菲勒家族参与投资土豆网
- proDAD Adobe pr cc2020 会声会影视频转场特效制作软件,滤镜特效插件
- 【数字逻辑设计】电路原理图
- java 华氏温度转换为摄氏温度
- php mud游戏源码,mud手游源码,mud安卓端源码,谁与争锋mud源码:关于MUD纯文字游戏架设(回答得好加分100)(开源mud游戏框架)-南开游戏网...
- 04【Verilog实战】SPI协议底层硬件接口设计(附源码RTL/TB)
- 基于FPGA的火焰识别系统开发——简化版
- window cmd 创建文本文件
- java 处理物料清单_ERP之物料清单(BOM)
- Latex论文排版——图片
- PDFCrackers Plus版
热门文章
- Cookie和Session 登录
- 19年8月 字母哥 番外篇:周边技术生态
- git rebase命令(转)
- java流与文件——操作文件
- jdk8 npe_JDK 14中更好的NPE消息
- sbe 详解_内部简单二进制编码(SBE)
- apache poi_将HTML转换为Apache POI的RichTextString
- sidecar_Spring Cloud Sidecar –节点初始化
- Apache Camel 3.2 – Camel的无反射配置
- 操作方法:具有多个Mongo存储库和Kotlin的Spring Boot 2 Web应用程序