maven的 <properties> 标签统一管理版本出现的错误

在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>

然后发现神奇的好了,然后再写回去。也正常了

原因有待调查。。。  有可能是远程仓库配置好了的缘故。

猜你喜欢

转载自blog.csdn.net/Mint6/article/details/82829870