1. 程式人生 > >maven的 標籤統一管理版本出現的錯誤

maven的 標籤統一管理版本出現的錯誤

在pom中使用<properties>標籤統一管理jar版本號

<properties>
<hutool.version>4.1.14</hutool.version>
</properties>

然後在下面引入

   <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-all</artifactId>
                <version>${hutool.version}</version>
            </dependency>

maven一直提示找不到這個jar,檢查了一下配置遠端倉庫。

 <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  <!--   <mirror>
      <id>CN</id>
      <name>OSChina Central</name>                                                                                                                       
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </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>

給出一個遠端倉庫配置,

然後就把這個給註釋掉

<properties>
  <!--<hutool.version>4.1.14</hutool.version>-->
</properties>

直接寫好

 <dependency>
                <groupId>cn.hutool</groupId>
                <artifactId>hutool-all</artifactId>
                <version>4.1.9</version>
            </dependency>

然後發現神奇的好了,然後再寫回去。也正常了

原因有待調查。。。  有可能是遠端倉庫配置好了的緣故。