maven 私服:artifactory

1.安装。解压就可以了
2.启动。双击bin目录下的artifactory.bat文件。如果出错,可能是没有安装jdk或者jdk版本低于1.5导致。安装jdk1.5以上后,在artifactory.bat前面添加set JAVA_HOME=/your/jdk/install/directory
3.查看。打开浏览器,进入地址:http://localhost:8081/artifactory,用admin/password登录。
4.在使用maven时,pom.xm文件中<project>的标签内添加:
<repositories>
        <repository>
            <id>artifactory</id>
            <name>my artifactory</name>
            <url>http://192.168.0.253:8081/artifactory/repo</url>
        </repository>
    </repositories>
 
    <pluginRepositories>
        <pluginRepository>
            <id>artifactory</id>
            <name>my artifactory</name>
            <url>http://192.168.0.253:8081/artifactory/plugins-releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>
5.发布jar文件。当出现Unable to download the artifact from any repository错误时,请发布repository中没有的工件。
在发布工件前,请确认官网上没有该工件。有时官网上会有较新的工件,可以修改该工件的版本,与官网一致。官网上工件查询地址:
http://mvnrepository.com/
如果确定需要的工件官网上没有,那么需要自己手工添加工件。
比如,构建richfaces的demo时,报错:
Reason: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command:
    mvn install:install-file -DgroupId=org.richfaces.ui -DartifactId=richfaces-ui /
        -Dversion=3.1.2.GA -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:     mvn deploy:deploy-file -DgroupId=org.richfaces.ui -DartifactId=richfaces-ui /
        -Dversion=3.1.2.GA -Dpackaging=jar -Dfile=/path/to/file /
         -Durl=[url] -DrepositoryId=[id]


  org.richfaces.ui:richfaces-ui:jar:3.1.2.GA

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  maven-repository.dev.java.net (http://download.java.net/maven/1),
  artifactory (http://192.168.0.253:8081/artifactory/repo)

这时,就得发布所需的jar包
  mvn deploy:deploy-file -DgroupId=org.richfaces.ui -DartifactId=richfaces-ui -Dversion=3.1.2.GA -Dpackaging=jar -Dfile=/media/sda2/MyDownloads/richfaces-ui-3.1.2.GA/lib/richfaces-ui-3.1.2.GA.jar -Durl=http://192.168.0.253:8081/artifactory/libs-releases -DrepositoryId=artifactory
出现错误:
Error deploying artifact: Failed to transfer file: http://192.168.0.253:8081/artifactory/repo/org/richfaces/ui/richfaces-ui/3.1.2.GA/richfaces-ui-3.1.2.GA.jar. Return code is: 401
这时,就要在~/.m2/settings.xml中添加如下的服务器登录信息(如果目录下没有settings.xml文件,创建一个):
<servers>
    <server>
      <id>artifactory</id>
      <username>admin</username>
      <password>password</password>
    </server>
  </servers> 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值