Nexus下载地址:https://www.sonatype.com/download-oss-sonatype
选择相应的版本下载后,本人下载的是nexus-2.12.0-01-bundle.zip版本。nexus默认是和jetty集成的,如果要在Tomcat环境下使用,则按照如下步骤进行配置即可:
1,解压文件后后得到两个文件夹,[nexus-2.12.0-01]及[sonatype-work],[nexus-2.12.0-01]文件夹看到他的结构类似于Tomcat服务器。
将这两个文件夹复制到一个目录下,可以不用在Tomcat的webapps目录下也行。本人是在webapps下面创建了一个Nexus的文件夹,并将这两个文件复制到里面,如:F:\Tomcat8\apache-tomcat-8.5.9\webapps\Nexus。
2.把nexus-2.12.0-01\lib文件夹下面的除了javax.servlet*.jar及jetty*jar的所有jar包文件复制到nexus-2.12.0-01\nexus\WEB-INF\lib下面。
3.修改nexus-2.12.0-01\nexus\WEB-INF\classes\nexus.properties文件修改:nexus-work=F:/Tomcat8/apache-tomcat-8.5.9/webapps/Nexus/sonatype-work/nexus,注意斜杆的方向。
4.修改Tomcat的server.xml文件,在Host节点内添加Context节点,修改后如下:
1 2 3 4 5 6 7 8 9 | < Host name= "localhost" app Base = "webapps" unpack WARs = "true" auto Deploy = "true" > < Valve class Name = "org.apache.catalina.valves.AccessLogValve" directory= "logs" prefix= "localhost_access_log" suffix= ".txt" pattern= "%h %l %u %t " %r " %s %b" /> < Context doc Base = "F:\Tomcat8\apache-tomcat-8.5.9\webapps\Nexus\nexus-2.12.0-01\nexus" path= "/nexus" reloadable= "true" /> </ Host > |
启动Tomcat,在浏览器打开地址http://localhost/nexus,我用的是80端口,成功了。
5.修改本地的Maven配置文件内容
找到用户的.m2/setting.xml文件,也可以在Eclipse的Preferences->Maven->User Settings->User Settings内找到。
打开此文件,在此文件内添加本地的Maven仓库目录,如:
<localRepository>F:\Maven\MavenRepository</localRepository>
添加Maven镜像仓库位置:
1 2 3 4 5 6 7 8 9 10 | <mirror> <id>nexus</id> <mirror Of >*</mirror Of > <url>http://localhost/nexus/content/groups/public/</url> </mirror> <mirror> <id>snapshots</id> <mirror Of >snapshots</mirror Of > <url>http://localhost/nexus/content/repositories/snapshots/</url> </mirror> |
配置Profile及激活Profile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <profile> <id>development</id> <repositories> <repository> <id>central</id> <url>http://localhost/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <plugin Repositories > <plugin Repository > <id>central</id> <url>http://localhost/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </plugin Repository > </plugin Repositories > </profile> </profiles> <active Profiles > <active Profile >development</active Profile > </active Profiles > |
添加认证信息,填写正确的用户名密码
1 2 3 4 5 6 7 8 9 10 | <server> <id>nexus-releases</id> <username>admin</username> <password>admin</password> </server> <server> <id>nexus-snapshots</id> <username>admin</username> <password>admin</password> </server> |
6.构建项目并部署到Nexus仓库,修改pom文件(自动部署),这里到底是部署到release仓库还是snapshots,具体还要看项目的version的后缀是snapshots还是release。
1 2 3 4 5 6 7 8 9 10 11 | <!-- 自动部署构件到 Nexus 仓库 --> <distribution Management > <repository> <id>nexus-releases</id> <url>http://localhost/nexus/content/repositories/releases/</url> </repository> <snapshot Repository > <id>nexus-snapshots</id> <url>http://localhost/nexus/content/repositories/snapshots/</url> </snapshot Repository > </distribution Management > |
执行命令:mvn clean deploy 部署到Nexus仓库内。
最终部署到Nexus仓库效果如下,项目的version为0.0.1-RELEASE
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 零经验选手,Compose 一天开发一款小游戏!
· 因为Apifox不支持离线,我果断选择了Apipost!
· 通过 API 将Deepseek响应流式内容输出到前端