Maven学习笔记(二)

私服应用

可以将自己或团队编写的项目编译成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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值