idea使用maven私服

nexus3中央仓库改为阿里云

参考:这里写链接内容 
找到中央仓库

这里写图片描述

然后修改成: 
这里写图片描述

http://maven.aliyun.com/nexus/content/groups/public/
  • 1

idea使用私服maven及对应配置

参考: 
这里写链接内容

首先,新建一个maven项目—自己新建吧。

然后, 
这里写图片描述

这里写图片描述

看到本机的maven 配置文件, 
这里写图片描述

打开来,然后: 
这里写图片描述 
添加我们的maven私服及servers—用来发布类库的。

格式如下:

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
    <!--内部maven-->
        <mirror>  
          <id>central</id>  
          <mirrorOf>*</mirrorOf>  
          <name>Central Repository</name>  
          <url>http://你仓库的地址/repository/maven-public/</url>  
      </mirror>  
        <!-- 阿里云仓库 -->
        <mirror>
            <id>alimaven</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>

        <!-- 中央仓库1 -->
        <mirror>
            <id>repo1</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo1.maven.org/maven2/</url>
        </mirror>

        <!-- 中央仓库2 -->
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo2.maven.org/maven2/</url>
        </mirror>
    </mirrors>
    <servers>     
     <server>  
         <id>nexus-releases</id>  
         <username>admin</username>  
         <password>你的密码</password>  
     </server>  
     <server>  
         <id>nexus-snapshots</id>  
         <username>admin</username>  
         <password>你的密码</password>  
     </server>    
 </servers>  
</settings>

发布快照及正式版本

maven(15),快照与发布,RELEASE与SNAPSHOT

在pom.xml文件最后添加distributionManagement发布管理节点:

这里写图片描述

例如:

    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://你的maven地址/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://你的maven地址/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
  • 注意一下
    <groupId>net.funfunle</groupId>
    <artifactId>baselib</artifactId>
    <!--<version>1.0-SNAPSHOT</version>-->
    <version>1.0.1-RELEASE</version>

groupid这些,

    <groupId>net.funfunle</groupId>
    <artifactId>baselib</artifactId>
    <!--<version>1.0-SNAPSHOT</version>-->
    <version>1.0.1-RELEASE</version>

决定发布的是正式版本release还是快照snapshot的是

    <!--<version>1.0-SNAPSHOT</version>-->
    <version>1.0.1-RELEASE</version>

版本号及发布类型,有一点也需要注意,snapshot快照允许重复发布更新同一个版本,而release是不允许的,release每次发布版本号都要加的。

发布方式: 
这里写图片描述

在mavenproject点击发布deploy。

新项目中引用发布的类库

maven2获取最新版本方式。

这里写链接内容 
maven pom文件详解

这里写图片描述

这里写图片描述

这里写图片描述

maven3获取最新版本方式 
这里写链接内容

Now I know this topic is old, but reading the question and the OP supplied answer it seems the Maven Versions Plugin might have actually been a better answer to his question:

In particular the following goals could be of use:

versions:use-latest-versions searches the pom for all versions which have been a newer version and replaces them with the latest version.
versions:use-latest-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the latest release version.
versions:update-properties updates properties defined in a project so that they correspond to the latest available version of specific dependencies. This can be useful if a suite of dependencies must all be locked to one version.
The following other goals are also provided:

versions:display-dependency-updates scans a project's dependencies and produces a report of those dependencies which have newer versions available.
versions:display-plugin-updates scans a project's plugins and produces a report of those plugins which have newer versions available.
versions:update-parent updates the parent section of a project so that it references the newest available version. For example, if you use a corporate root POM, this goal can be helpful if you need to ensure you are using the latest version of the corporate root POM.
versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project. For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules. (Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).
versions:lock-snapshots searches the pom for all -SNAPSHOT versions and replaces them with the current timestamp version of that -SNAPSHOT, e.g. -20090327.172306-4
versions:unlock-snapshots searches the pom for all timestamp locked snapshot versions and replaces them with -SNAPSHOT.
versions:resolve-ranges finds dependencies using version ranges and resolves the range to the specific version being used.
versions:use-releases searches the pom for all -SNAPSHOT versions which have been released and replaces them with the corresponding release version.
versions:use-next-releases searches the pom for all non-SNAPSHOT versions which have been a newer release and replaces them with the next release version.
versions:use-next-versions searches the pom for all versions which have been a newer version and replaces them with the next version.
versions:commit removes the pom.xml.versionsBackup files. Forms one half of the built-in "Poor Man's SCM".
versions:revert restores the pom.xml files from the pom.xml.versionsBackup files. Forms one half of the built-in "Poor Man's SCM".
Just thought I'd include it for any future reference.

这里写图片描述

譬如:

这里写图片描述

根据提供的引用内容,你遇到了在使用IDEAMaven时出现私服报错的问题。这可能是由于配置问题或者网络连接问题导致的。下面是一些可能的解决方法: 1. 检查Maven配置:确保你的Maven配置文件(settings.xml)中正确配置了私服的URL和凭据。你可以在该文件中添加以下内容: ```xml <servers> <server> <id>your_server_id</id> <username>your_username</username> <password>your_password</password> </server> </servers> ``` 请将`your_server_id`替换为私服的ID,`your_username`和`your_password`替换为你的私服凭据。 2. 检查网络连接:确保你的网络连接正常,并且可以访问私服的URL。你可以尝试使用浏览器或者命令行工具(如curl或wget)访问私服的URL,以确认是否可以正常连接。 3. 清理Maven缓存:有时候Maven缓存中的某些文件可能会导致问题。你可以尝试清理Maven的本地仓库缓存,然后重新构建项目。你可以使用以下命令清理Maven缓存: ```shell mvn dependency:purge-local-repository ``` 4. 更新Maven依赖:如果你的项目依赖的某些库已经更新了版本,但是私服中还没有同步更新,可能会导致报错。你可以尝试更新你的项目依赖,或者在Maven配置文件中添加其他可用的仓库。 希望以上方法能够帮助你解决问题。如果问题仍然存在,请提供更多的错误信息和具体的配置细节,以便我们能够更好地帮助你。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值