首页 > 解决方案 > 生成的 Spring pom.xml 导致错误“获取 http://maven.apache.org/POM/4.0.0 时出错”

问题描述

(我知道有类似的问题 - 但尝试了解决方案后我仍然卡住了)

我正在尝试使用 Spring 中的 Demo 项目并且无法使生成的 pom.xml 在 IntelliJ 下工作,我尝试了 IntelliJ 建议的解决 URI 未注册的解决方案 - 但这只会导致名义错误。

起初我认为这是一个网络错误,但在浏览器中加载网页时,它是 404s。这让我相信这是我的项目设置在某种程度上存在的问题。

我通过在 IntelliJ 中打开 pom.xml 然后单击“作为项目打开”来导入项目。

我的 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.5.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>prs.ttg.spring</groupId>
    <artifactId>test</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>test</name>
    <description>Test project for Spring Boot</description>

    <properties>
        <java.version>15</java.version>
    </properties>

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

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

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

</project>

没有任何依赖项被加载,我无法终生找到一个可行的解决方案。

我感谢帮助,并理解这是否只是一个愚蠢的问题 - 我是一个愚蠢的人

标签: javaxmlspringmavenintellij-idea

解决方案


确保在 Preferences | 中启用了Maven捆绑插件。插件。如果您使用代理 - 在 IDE 中设置代理设置:https ://www.jetbrains.com/help/idea/settings-http-proxy.html

如果您通过 File | 启用了 Maven 插件打开项目 新 | Project from Existing Sources 并选择pom.xml文件以从中导入项目。


推荐阅读