【2026最新】nexus3.90.x安装文件说明
Sonatype Nexus Repository Windows 版
本目录包含在 Windows 上运行 Nexus Repository 所需的脚本和可执行文件。
在 Windows 上将 Nexus Repository 安装为服务
nexus.exe文件是 Apache Commons Daemon 的 procrun 工具的副本。该可执行文件封装了运行 Nexus Repository 作为 Windows 服务所需的 Java 调用。
以管理员身份打开命令提示符,运行以下命令:
install-nexus-service.bat
此命令将使用默认设置安装 SonatypeNexusRepository 作为 Windows 服务:
- sonatype-work 目录将是分发包中包含的目录,位于此脚本的相对路径下。
- Nexus Repository 将使用捆绑的 JDK 21 运行时。
自定义 sonatype-work 目录路径
如果要使用不同的 sonatype-work 目录,请提供绝对路径作为参数:
install-nexus-service.bat C:\my-sonatype-work
自定义 Java 运行时
如果要使用不同的 JDK,有两种选择:
- 将环境变量
INSTALL4J_JAVA_HOME_OVERRIDE设置为要使用的 JDK 的绝对路径。 - 修改 nexus.rc 文本文件,并在
app_java_home变量中指定要使用的 JDK 的绝对路径。
将 Nexus Repository 作为 Windows 服务启动
安装服务后,可以使用 Windows 服务控制面板启动和停止它。
如果需要从命令行停止服务,可以运行命令:
nexus.exe stop SonatypeNexusRepository
要从命令行启动服务,请运行命令:
nexus.exe start SonatypeNexusRepository
要卸载服务,请运行命令:
sc delete SonatypeNexusRepository
从命令行启动 Nexus Repository
如果要将 Nexus Repository 作为控制台应用程序而不是服务运行,在安装服务后,可以运行命令:
nexus.exe run SonatypeNexusRepository
这将在前台启动 Nexus Repository 应用程序,可以通过按Ctrl+D和Ctrl+C停止它。可能需要尝试几次才能停止。这对于调试很有用,但不建议在生产环境中使用。
如果在服务运行时尝试使用此命令,将会收到类似以下的错误:
C:\nexus\nexus-3.79.1\bin>nexus.exe run SonatypeNexusRepository [2025-04-09 21:51:04] [info] ( prunsrv.c:2084) [ 7340] Apache Commons Daemon procrun (1.4.1.0 64-bit) started. [2025-04-09 21:51:04] [info] ( prunsrv.c:1911) [ 7340] Debugging 'SonatypeNexusRepository' service... [2025-04-09 21:51:04] [debug] ( prunsrv.c:1681) [ 7340] Inside serviceMain()... [2025-04-09 21:51:04] [debug] ( prunsrv.c:1127) [ 7340] reportServiceStatusE: dwCurrentState = 2 (SERVICE_START_PENDING), dwWin32ExitCode = 0, dwWaitHint = 3000 milliseconds, dwServiceSpecificExitCode = 0. [2025-04-09 21:51:04] [info] ( prunsrv.c:1426) [ 7340] Starting service... [2025-04-09 21:51:04] [error] ( prunsrv.c:1438) [ 7340] Pid file 'C:\nexus-again\nexus-3.80.0-SNAPSHOT-win-x86_64\sonatype-work\nexus3\log\nexus.pid' exists. [2025-04-09 21:51:04] [error] ( prunsrv.c:1438) [ 7340] The process cannot access the file because it is being used by another process. [2025-04-09 21:51:04] [error] ( prunsrv.c:1862) [ 7340] ServiceStart returned 1. [2025-04-09 21:51:04] [error] ( prunsrv.c:1862) [ 7340] The process cannot access the file because it is being used by another process. [2025-04-09 21:51:04] [debug] ( prunsrv.c:1127) [ 7340] reportServiceStatusE: dwCurrentState = 1 (SERVICE_STOPPED), dwWin32ExitCode = 1066, dwWaitHint = 0 milliseconds, dwServiceSpecificExitCode = 1. [2025-04-09 21:51:04] [info] ( prunsrv.c:1913) [ 7340] Debug service finished with exit code 1. [2025-04-09 21:51:04] [error] ( prunsrv.c:2181) [ 7340] Apache Commons Daemon procrun failed with exit value: 3 (failed to run service as console application). [2025-04-09 21:51:04] [error] ( prunsrv.c:2181) [ 7340] The process cannot access the file because it is being used by another process. The process cannot access the file because it is being used by another process. Failed to run service as console application. C:\nexus\nexus-3.79.1\bin>