Maven(二)-- 搭建私服,上传jar

一、在setting中配置 私服的镜像,在mirrors标签中加上:

<!--第一步  配置私服的镜像-->
<mirror>
     <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
     <id>nexus</id>
     <mirrorOf>*</mirrorOf>
     <!-- url对应发私服的 Public Repositories -->
     <url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>    

二、nexus工厂的配置,在profiles标签中加上:

<profile>
  <id>nexus</id>
    <!--所有请求均通过镜像 -->
    <repositories>
         <repository>
            <id>central</id>
            <url>http://central</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
         </repository>
    </repositories>
    <pluginRepositories>
          <pluginRepository>
             <id>central</id>
             <url>http://central</url>
             <releases><enabled>true</enabled></releases>
             <snapshots><enabled>true</enabled></snapshots>
          </pluginRepository>
     </pluginRepositories>
</profile>

三、激活profile配置

<!--第三步  激活profile配置 -->
  <activeProfiles>
     <!--make the profile active all the time -->
     <activeProfile>nexus</activeProfile>
  </activeProfiles>

四、在pom.xml中配置

<repositories>
     <repository>
         <id>central</id>
         <url>http://localhost:8081/nexus/content/groups/public/</url>
         <releases><enabled>true</enabled></releases>
         <snapshots><enabled>true</enabled></snapshots>
     </repository>
</repositories>
<pluginRepositories>
     <pluginRepository>
         <id>central</id>
         <url>http://localhost:8081/nexus/content/groups/public/</url>
         <releases><enabled>true</enabled></releases>
         <snapshots><enabled>true</enabled></snapshots>
      </pluginRepository>
 </pluginRepositories>

五、配置上传到私服,在pom中:

<distributionManagement>
    <repository>
        <id>releases</id>
        <name>Internal Releases</name>
        <url>http://localhost:8081/nexus/content/repositories/releases/</url>
    </repository>
</distributionManagement>

六、在nexus中配置权限

七、在pom.xml的servers标签中加上:

<server>
    <id>增加的maven库的id</id>
  <username>新建的名字</username>
  <password>pass</password>
</server>

八、更新jar遇到错误:

  was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced

  解决办法:去自己的.m2 文件夹下把 xxx.lastUpdated 文件全部删掉,重新运行maven,ok!

  

时间: 2024-08-07 20:07:11

Maven(二)-- 搭建私服,上传jar的相关文章

Nexus3.0搭建私服上传JAR包 Windows10

背景 近期换了一个项目组,用的是公司自研产品,涉及到很多内部JAR包引用,版本号很多,每次更新都是产品部给出jar包,项目组成员各自复制一套本地替换,来了新人各种安装配置,复杂度太高,这不,我一来,又是这里给我几个包又是那里替换几个引用,环境整的头大.Nexus 私服就是解决这问题的关键. 其实几年前,就给这边搭过一次nexus2.0,我走了后似乎就没用过了,废话不多说.再来一遍呗. 版本 JDK: 1.8.0_151 (请自行解决安装) Nexus: 3.0.0-03 Maven: apach

maven命令学习-发布上传jar包-deploy

Maven学习六之利用mvn deploy命令上传包 转http://blog.csdn.net/woshixuye/article/details/8133050 mvn:deploy在整合或者发布环境下执行,将最终版本的包拷贝到远程的repository,使得其他的开发者或者工程可以共享. 以将ojdbc14传到nexus中的thirdparty为例 一 配置settings.xml 因为nexus是需要登陆操作,当然可以通过配置免登陆,这是后话. 在settings.xml的<server

maven上传jar包到nexus私服后的存放路径 以及 使用IDEA上传jar包的步骤

maven上传jar包到nexus私服的方法,网上大神详解很多,那么上传后的jar包存放到哪里了呢? 在下使用nexus3.2.1版本,在本地搭建了私服,使用maven上传jar包.最后结果如下: 点进去后展示的是: 这让我一度以为是以jar包的形式保存在本地,但事实证明,保存在本地的最终是一个 .bytes 类型的文件,它的默认路径在\nexus-3.2.1-01-win64\sonatype-work\nexus3\blobs\default\content下面 即使jar包是同样的,但是d

如何上传jar包至Maven私服

如何上传jar包至Maven私服 1.通过浏览器进入,点击右上角的. 2.在弹出的登录窗口中输入用户名和密码. 3.登录成功之后,点击左侧列表中的Views/Respsitories-->Respsitories. 4.在打开的标签页中,选择3rd party,我们自己的jar包都要上传到3rdparty中.在下方的窗片中,可以浏览到所有的第三方的jar包. 5.点击下方窗片的,准备上传我们自己的包. GAV Definition 选择:GAVParameters. 依次填写Group.Arti

maven上传jar到私服

上传jar到nexus私服比较简单,不过不会常操作,经常会过一段时间用一回,因此很容易到用的时候又忘了. 手动上传就是在nexus中选择一个hosted仓库,artifact upload,GAV的方式,选择一个jar文件添加进去,最后upload就可以了. 手上有个snapshots类型的jar,nexus上的3rd party是release类型的仓库,不能上传snapshots jar.可nexus中当前的snapshots仓库并没有找到artifact upload这项. 找了下,mav

Maven上传jar包到私服

1.认证,在M2_HOME/conf/settings.xml配置用户名密码 2.在将要上传项目的pom.xml中配置jar包上传路径url <distributionManagement> <repository> <id>releases</id> <url>http://127.0.0.1:8081/repository/maven-releases/</url> </repository> <snapshot

(转)上传jar包到nexus私服

场景:在使用私服Nexus时候经常需要上传jar包,但是对上传jar包的方式不是很熟悉,所以很有必要学习下. 1 通过网页上传 GAV Definition:选择GAV Parameters 输入JAR包对应的:Group\Artifact\verison\ 选择JAR 第三步上传包, 第四步add artifact 最后update artifact. 这样包上传成功.POM可以用了. 这种方法只是上传了jar包.通过maven引用当前jar,不能取得jar的依赖   from pom的方式,

使用Nexus管理Maven仓库时,上传带依赖的第三方jar

总所周知,使用Maven构建非常方便.在企业中使用Nexus创建私服来管理Maven时,需要上传很多没有开放源码的第三方Jar包.本文将讲述当第三方Jar包有很多并且互相有依赖时如何上传. 核心操作 自己编写POM 确保上传所有依赖 步骤 当需要导入DB2驱动时,需要db2jcc.jar,而db2jcc.jar又要依赖db2jcc_license_cu.jar,此时,导入方式如下 1.编写POM 手动编写db2jcc.jar的pom.xml,如下: <project ...> <mode

上传jar包到nexus私服

摘要 通过网页和maven两种方式,上传本地的jar到nexus私服,以及引用jar时,自动引用依赖 1通过网页上传 这种方法只是上传了jar包.通过maven引用当前jar,不能取得jar的依赖   from pom的方式,选择pom文件,以及jar.通过maven引入jar时,会自动加载jar的依赖 2通过maven的方式depoly 在maven的conf/setting.xml 配置nexus私服的管理账号 在servers标签下添加server    <server>       &

使用maven打包项目并上传到Linux服务器

maven打包: 项目右键Run as-->Maven build...-->  出来下面的界面,注意红色部分的填写,Goals填写package表示打包,下面的Skip Tests表示打包时不执行单元测试. 点击Run 就打包成功了,jar包在空间下/项目名/target下.没有打包配置文件. 将打包好的jar上传到Linux服务器: 首先通过cd 进入到需要上传的目录下,然后是输入rz命令回车,弹出窗口选择要上传的包,上传,最后通过ls命令查看有没有上传成功. 前两天通过这个方法上传成功了