私服应用
可以将自己或团队编写的项目编译成jar包放到局域网内服务器上,供大家使用。
私服安装
下载安装包解压到本地,在控制台执行命令安装。
进入到本地解压文件路径的bin目录下:
D:\maven\meven_server\nexus-2.12.0-01\bin
执行命令:
nexus install
,安装完成之后可以在服务里面找到nexus服务;启动nexus服务:
nexus start
私服默认访问地址:
localhost:8081/nexus/
私服仓库类型
类型 | 中文名 | 作用 |
---|---|---|
Hosted | 宿主仓库 | 存放本公司开发的jar包(正式版、测试版、第三方) |
Proxy | 代理仓库 | 代理中央仓库、Apache下测试版本的jar包 |
Group | 组仓库 | 包含Hosted和Proxy(实际应用时连接私服的组仓库) |
上传jar包到私服
在conf/setting.xml
<servers>
<server>
<id>deploymentRepo</id>
<username>repouser</username>
<password>repopwd</password>
</server>
<server>
<id>siteServer</id>
<privateKey>/path/to/private/key</privateKey>
<passphrase>optional; leave empty if not used.</passphrase>
</server>
</servers>
在项目的pom.xml文件中配置上传位置
<mirrors>
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
</mirrors>
执行命令发布项目到私服,即将项目打成jar包上传到私服:deploy
从私服下载jar包到本地仓库
在conf/setting.xml配置模板
<profiles>
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
<profile>
<id>env-dev</id>
<activation>
<property>
<name>target-env</name>
<value>dev</value>
</property>
</activation>
<properties>
<tomcatPath>/path/to/tomcat/instance</tomcatPath>
</properties>
</profile>
</profiles>
激活模板
<activeProfiles>
<activeProfile>alwaysActiveProfile</activeProfile>
<activeProfile>anotherAlwaysActiveProfile</activeProfile>
</activeProfiles>