简体   繁体   English

Intellij 在 pom.xml 中找不到 Maven 依赖项

[英]Intellij cannot find Maven Dependencies in pom.xml

I am new to the spring boot framework and I'm trying to import the Maven libraries, but I keep getting an error with my pom.xml.我是 Spring Boot 框架的新手,我正在尝试导入 Maven 库,但是我的 pom.xml 一直出现错误。 Please Help!请帮忙!

Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from https://repo.maven.apache.org/maven2传输失败被缓存在本地存储库中,不会重新尝试解析直到 Central 的更新间隔已过或强制更新。 Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to central ( https://repo.maven.apache.org/maven2 ): repo.maven.apache.org原始错误:无法传输工件 org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE from/to central ( https://repo.maven.apache.org/maven2):repo 。 maven.apache.org

Dependency 'org.springframework.boot:spring-boot-starter-web:' not found less... (Ctrl+F1) Inspection info: Inspects a Maven model for resolution problems.依赖 'org.springframework.boot:spring-boot-starter-web:' not found less... (Ctrl+F1) 检查信息:检查 Maven 模型的解决问题。

Plugin 'org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE' not found less... (Ctrl+F1) Inspection info: Inspects a Maven model for resolution problems.插件 'org.springframework.boot:spring-boot-maven-plugin:2.0.4.RELEASE' not found less... (Ctrl+F1) 检查信息:检查 Maven 模型以解决问题。

Here is my pom.xml below:下面是我的 pom.xml:

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

<groupId>com.cierra</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.4.RELEASE</version>
</parent>


<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<properties>
    <java.version>1.8</java.version>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.0.4.RELEASE</version>
        </plugin>
    </plugins>
</build>


</project>

This maybe due to the reason that it is not able to connect and transfer dependencies specified in pom.xml file.这可能是由于它无法连接和传输 pom.xml 文件中指定的依赖项的原因。 The details where it is trying to connect must be mentioned in your settings.xml under .m2 folder必须在 .m2 文件夹下的 settings.xml 中提及它尝试连接的详细信息

Try adding the pluginRepositories in your pom.xml file:尝试在 pom.xml 文件中添加 pluginRepositories:

<pluginRepositories>
    <pluginRepository>
        <id>spring-snapshots</id>
        <url>http://repo.spring.io/libs-snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

try adding following repository elements inside repositories element in your pom.xml尝试在 pom.xml 中的 repositories 元素中添加以下存储库元素

<repository>
        <id>spring-snapshots</id>
        <name>Spring Snapshots</name>
        <url>https://repo.spring.io/snapshot</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>spring-milestones</id>
        <name>Spring Milestones</name>
        <url>https://repo.spring.io/milestone</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

If this set well, change your updatePolicy settings.如果此设置良好,请更改您的 updatePolicy 设置。

 <repository>
      <id>myRepo</id>
      <name>My Repository</name>
      <releases>
        <enabled>false</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
     </repository>

Refer question.参考问题。

The problem was I was behind a proxy that was blocking my pom.xml from running properly.问题是我在阻止我的 pom.xml 正常运行的代理后面。 After using a VPN to run the application, it works fine now.使用 VPN 运行应用程序后,它现在工作正常。

Change Your Maven Version Ad Check Again.再次更改您的 Maven 版本广告检查。

Install Maven and Then Go to File/setting/build,execution,.../build Tools/maven And Change Maven Home Directory to Your Install Maven Directory安装 Maven,然后转到 File/setting/build,execution,.../build Tools/maven 并将 Maven Home Directory 更改为您的安装 Maven 目录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM