idea maven找不到依赖

相信你们开发中老是遇到maven爆红的状况,其中的缘由可能有maven仓库源加载缓慢,能够在项目中配置本身的私服或者配置国内的景象源,经常使用镜像源maven的settings文件配置
        ```
        <mirrors>
 <mirror>
    <id>aliyun-central</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun-central</name>
    <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<mirror>
    <id>nexus-osc</id>
    <mirrorOf>osc-central</mirrorOf>
    <name>Nexus osc</name>
    <url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
<mirror>
    <id>nexus-mvn</id>
    <mirrorOf>mvn-central</mirrorOf>
    <name>Nexus mvn</name>
    <url>http://mvnrepository.com</url>
</mirror>
<mirror>
    <id>nexus-spring</id>
    <mirrorOf>spring-central</mirrorOf>
    <name>Nexus spring</name>
    <url>https://repo.spring.io/libs-milestone</url>
</mirror>

</mirrors>spring

<profiles>
<profile>
  <id>ali</id>
  <activation>
    <jdk>1.8</jdk>
  </activation>

  <repositories>
    <repository>
      <id>ali</id>
      <name>Repository for JDK 1.8 builds</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
      <layout>default</layout>
    </repository>
  </repositories>
</profile>
<profile>
    <id>mvn</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>

  <repositories>
    <repository>
      <id>mvn</id>
      <name>Repository for JDK 1.8 builds</name>
      <url>http://mvnrepository.com</url>
      <layout>default</layout>
      <snapshotPolicy>always</snapshotPolicy>
    </repository>
  </repositories>
</profile>
<profile>
    <id>spring</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
    <repository>
        <id>spring</id>
        <name>spring-central</name>
        <url>https://repo.spring.io/libs-milestone</url>
        <layout>default</layout>
        <snapshotPolicy>always</snapshotPolicy>
    </repository>

</profile>
</profiles>
  <activeProfiles>
<activeProfile>ali</activeProfile>
<activeProfile>spring</activeProfile>
<activeProfile>mvn</activeProfile>

</activeProfiles>maven

配置好以后将ide的maven路径修改
        ![](https://s4.51cto.com/images/blog/202010/17/f0d678a24b400f286f6b608b3b783aec.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
        刷新maven配置
        ![刷新配置](https://s4.51cto.com/images/blog/202010/17/2066bfc32af97c0d6540bea7018c3d21.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
        上述操做以后仍是爆红,实际上maven仓库里面有了对应的jar包了,此时只能命令行执行mvn clean compile 或者mvn clean install 看控制台错误,检查报错的jar包是否是本身公司的内部jar包,若是是,找到对应jar包的版本路径和实际maven的路径 版本是否一一对应
        ![](https://s4.51cto.com/images/blog/202010/17/f30392ba94bc7503ee5d7e1fcdb3fc2c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
        上图中的common 1.0在我本地不存在,最后找到pom文件检查,发现如今的版本是1.0-SNAPSHOT,改完版本从新执行maven clean installl就能够了。为何别人的能够,是由于别人在改版本以前已经编译过了,有了对应的jar包在本地仓库了因此别人的正常你的不正常,加载缓慢重启ide从新更新便可。
本站公众号
   欢迎关注本站公众号,获取更多信息