nexus-3.16.2-01文件夹放的是nexus服务器相关的文件
sonatype-work放的是nexus工作的数据文件,上传下载的jar包就在这个文件夹下面
压缩包nexus-3.16.1-02\etc路径下的nexus-default.properties文件们是用来配置访问端口的,默认8081端口
命令提示符中进去C:\web_soft\nexus\nexus-3.16.1-02\bin文件夹
如果不安装服务是没有办法启动的. 如果有你可以告诉我, 我会更新我的文章内容.
使用命令: nexus.exe /install nexus3
如果你使用的 Windows PowerShell 请在exe前加上 .\ 执行的命令是: .\nexus.exe /install nexus3
可能会出现的错误: could not open SCManager 这个是因为没有使用管理员身份启动cmd, 使用管理员启动即可.
2.第二种方式使用命令: nexus.exe /start
启动成功之后, 可以使用以下域名访问:http://localhost:8081
默认用户名/密码: admin admin123
可能会出现的错误: Could not start service. Error code: 1060 如果出现这个错误就把启动命令改为: nexus.exe /run
【代理资源库】:就是配置了外网的maven远程仓库地址的资源库,本地找不到,就会通过代理资源库中的地址,找到远程仓库,从远程仓库中下载所需要的jar。
【托管资源库】:就是放在本地的资源库,零零散散的jar,从远程仓库( central repository )中下不到,只能自己在网上找,找到jar下载下来,放在托管资源库中,交给nexus统一管理。不然哪天想去用连接数据库的jar包,还得自己翻磁盘,多麻烦。
【组资源库】 :组资源库中并没有jar包,而是把代理资源库和托管资源库统一配置到组资源库中,然后组资源库作为一个唯一的public提供给所有人使用。就像工人1+工人2把自己的账单统一给包工头,让包工头去跟老板结账是一个道理。
在创建 repository之前,还是需要先设定一个指定的文件存储目录,便于统一管理
阿里云的maven中央仓库地址:http://maven.aliyun.com/nexus/content/groups/public/
默认远程Maven地址:https://repo1.maven.org/maven2/
创建hosted repository 托管资源库
Hosted有三种方式,Releases、SNAPSHOT、Mixed
Releases: 一般是已经发布的Jar包
Snapshot: 未发布的版本
Mixed:混合的
希望将hosted repositories【托管资源库】的顺序放在proxy repositories【代理资源库】之前,因为一个group【组资源库】中可以涵括这些托管资源库和代理资源库。而一整个的group是作为一个public,一个接口给别人使用的。所以当查找架包的时候,如果代理资源库在前面,那就是先从远程去查找jar,而不是先从托管资源库(本地仓库)去查找是否有jar。这样访问外网的消耗比起来在本地查找,当然是将托管资源库放在代理资源库之前的优先位置了
Maven的中央仓库地址默认是:https://repo.maven.apache.org/maven2/,可以通过修改settings.xml文件来修改默认的中央仓库地址:
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>C:/shwz_data/repositorylocalRepository>
<interactiveMode>trueinteractiveMode>
<offline>falseoffline>
<servers>
<server>
<id>nexus-releasesid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-snapshotsid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-proxyid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-groupid>
<username>adminusername>
<password>admin123password>
server>
servers>
<mirrors>
<mirror>
<id>alimavenid>
<name>aliyun mavenname>
<url>http://maven.aliyun.com/nexus/content/groups/public/url>
<mirrorOf>centralmirrorOf>
mirror>
mirrors>
<profiles>
<profile>
<id>nexusid>
<activation>
<activeByDefault>trueactiveByDefault>
<jdk>1.8jdk>
activation>
<repositories>
<repository>
<id>nexus-groupid>
<url>http://localhost:8081/repository/nexus-group/url>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>trueenabled>
snapshots>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-groupid>
<url>http://localhost:8081/repository/nexus-group/url>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>trueenabled>
snapshots>
pluginRepository>
pluginRepositories>
profile>
<profile>
<id>jdk-1.8id>
<activation>
<activeByDefault>trueactiveByDefault>
<jdk>1.8jdk>
activation>
<properties>
<maven.compiler.source>1.8maven.compiler.source>
<maven.compiler.target>1.8maven.compiler.target>
<maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
properties>
profile>
profiles>
<activeProfiles>
<activeProfile>nexusactiveProfile>
<activeProfile>jdk-1.8activeProfile>
activeProfiles>
settings>
在maven的setting.xml文件配置账号和密码
<servers>
<server>
<id>nexus-releasesid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-snapshotsid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-proxyid>
<username>adminusername>
<password>admin123password>
server>
<server>
<id>nexus-groupid>
<username>adminusername>
<password>admin123password>
server>
servers>
在你项目(这个项目就是你准备发布的jar)pom.xml中增加一段这样的代码
<distributionManagement>
<repository>
<id>nexus-releasesid>
<name>Releasesname>
<url>http://localhost:8081/repository/shwz-releases/url>
repository>
<snapshotRepository>
<id>nexus-snapshotsid>
<name>Snapshotsname>
<url>http://localhost:8081/repository/nexus-snapshots/url>
snapshotRepository>
distributionManagement>