首页 > 解决方案 > IDEA开发环境下maven如何管理java项目的依赖下载

问题描述

我在 IDEA 编码。当我使用maven时,我遇到了一个奇怪的问题。

首先IDEA配置了本地maven环境,使用本地配置文件setting.xml,配置了nexus节点。

其次,我从 eclipse 中导入了一个基于 maven 的项目。

我确信setting.xml100% 正确。但是IDEA不是从nexus下载jar,而是从maven url下载。

我不知道发生了什么。

我清理~\m2文件夹,清理'lib' floder。但它也没有成功。

想知道IDEA如何使用maven下载jar,如何确定url,什么情况下会下载失败。

https://www.jetbrains.com/help/idea/settings-build-execution-deployment.html

我隐藏了 groupId、artifactId、name 和密码,但我确定它是正确的。

我隐藏了一些依赖,它太多了。

父 Pom 处于关联中。

<?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">
   <localRepository>D:\Software\maven\repo</localRepository>

  <pluginGroups>
  </pluginGroups>

  <proxies>
  </proxies>

  <servers>
    <server>
      <id>nexus</id>
      <username>name</username>
      <password>pwd</password>
    </server>
    <server>
      <id>y-snapshots</id>
      <username>name</username>
      <password>pwd</password>
    </server>
    <server>
      <id>y-releases</id>
      <username>name</username>
      <password>pwd</password>
    </server>
  </servers>

  <mirrors>
     <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://192.168.31.169:8081/repository/maven-public/</url>
    </mirror>
  </mirrors>


  <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>
  </profiles>

  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.s</groupId>
        <artifactId>ss</artifactId>
        <version>1.4.0-SNAPSHOT</version>
    </parent>

    <artifactId>s-common</artifactId>
    <version>1.5.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    </dependencies>

</project>

标签: javamavenintellij-idea

解决方案


检查您的设置:文件->设置 在此处输入图像描述


推荐阅读