Jfrog Artifactory 上传和下载jar

Jfrog Artifactory 上传和下载jar,第1张

目录
  • 1. 上传jar
    • 1.1 创建工程
    • 1.2 修改pom
    • 1.3 发布
  • 2. 下载jar

相关文章
Jfrog Artifactory 安装
Jfrog Artifactory 仓库配置
Jfrog Artifactory 上传和下载jar

1. 上传jar
  • 这里提前创建好snapshort和release仓库

  • maven工程中上传jar参考https://www.jfrog.com/confluence/display/JFROG/Maven+Artifactory+Plugin
1.1 创建工程
  • 这里创建了一个新的maven工程,只有一个util文件,用来后续测试使用

1.2 修改pom
  • 最重要的部分

  • 完整配置


<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>

    <groupId>org.examplegroupId>
    <artifactId>demoartifactId>
    <version>1.0-SNAPSHOTversion>

    <name>demoname>
    
    <url>http://www.example.comurl>

    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
        <maven.compiler.source>1.7maven.compiler.source>
        <maven.compiler.target>1.7maven.compiler.target>
    properties>

    <dependencies>

    dependencies>

    <build>
        <pluginManagement>
            <plugins>
                
                <plugin>
                    <artifactId>maven-clean-pluginartifactId>
                    <version>3.1.0version>
                plugin>
                
                <plugin>
                    <artifactId>maven-resources-pluginartifactId>
                    <version>3.0.2version>
                plugin>
                <plugin>
                    <artifactId>maven-compiler-pluginartifactId>
                    <version>3.8.0version>
                plugin>
                <plugin>
                    <artifactId>maven-surefire-pluginartifactId>
                    <version>2.22.1version>
                plugin>
                <plugin>
                    <artifactId>maven-jar-pluginartifactId>
                    <version>3.0.2version>
                plugin>
                <plugin>
                    <artifactId>maven-install-pluginartifactId>
                    <version>2.5.2version>
                plugin>
                <plugin>
                    <artifactId>maven-deploy-pluginartifactId>
                    <version>2.8.2version>
                plugin>
                
                <plugin>
                    <artifactId>maven-site-pluginartifactId>
                    <version>3.7.1version>
                plugin>
                <plugin>
                    <artifactId>maven-project-info-reports-pluginartifactId>
                    <version>3.0.0version>
                plugin>
            plugins>
        pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jfrog.buildinfogroupId>
                <artifactId>artifactory-maven-pluginartifactId>
                <version>3.2.3version>
                <inherited>falseinherited>
                <executions>
                    <execution>
                        <id>build-infoid>
                        <goals>
                            <goal>publishgoal>
                        goals>
                        <configuration>
                            <deployProperties>
                                <gradle>awesomegradle>
                                <review.team>qareview.team>
                            deployProperties>
                            <publisher>
                                <contextUrl>http://192.168.42.111:8082/artifactorycontextUrl>
                                <username>adminusername>
                                <password>APBTv8cxBHpUAypUNZEy4KSf2xtpassword>
                                <repoKey>fisher-libs-releaserepoKey>
                                <snapshotRepoKey>fisher-libs-snapshotsnapshotRepoKey>
                            publisher>
                        configuration>
                    execution>
                executions>
            plugin>
        plugins>
    build>
    
project>

  • 配置好地址,用户名、密码、snapshort仓库、release仓库
  • 密码使用的是加密后的,获取方法如下


  • 仓库可以使用虚拟仓库,也可以使用本地仓库,在fisher-libs-release和fisher-libs-snapshot后面带上-local即可
1.3 发布
  • 这里需要注意的是,如果版本号后面带了SNAPSHOT,则只会发布到snapshot仓库;不带SNAPSHOT,才会发布到release仓库

  • 在Terminal下,执行mvn deploy命令

  • 查看上传的jar

  • 将jar上传到release仓库中,先修改版本号再发布

  • 这时候release仓库已经有1.1版本的jar了

2. 下载jar
  • 在项目中使用时,在pom文件中添加下面代码,不需要用户名密码也可以下载jar

  • 这里是新建的一个新的springboot工程,完整的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.6.7version>
        <relativePath/> 
    parent>
    <groupId>com.examplegroupId>
    <artifactId>demo1artifactId>
    <version>0.0.1-SNAPSHOTversion>
    <name>demo1name>
    <description>demo1description>
    <properties>
        <java.version>1.8java.version>
    properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-starter-webartifactId>
        dependency>

        <dependency>
            <groupId>org.examplegroupId>
            <artifactId>demoartifactId>
            <version>1.1version>
        dependency>
    dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
        plugins>
    build>
    <repositories>
        <repository>
            <id>fisher-libs-releaseid>
            <name>fisher-libs-releasename>
            <url>http://192.168.42.111:8081/artifactory/fisher-libs-releaseurl>
            <releases>
                <enabled>trueenabled>
            releases>
        repository>
    repositories>
project>

  • 使用jar内的方法

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/877637.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存