`
lvyanglin
  • 浏览: 84299 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

maven 二方库发布

阅读更多
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>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics