【问题标题】:Dependency 'org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE' not found未找到依赖项 'org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE'
【发布时间】:2020-05-20 09:08:56
【问题描述】:

我在创建简单的spring boot Web 应用程序时遇到问题。我正在使用 Intellij Idea IDE 构建这个应用程序。存在与依赖相关的问题。 Intellij 说 - Dependency 'org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE' not found(in pom.xml)。

详细错误信息:

Dependency 'org.springframework.boot:spring-boot-starter-web:2.3.0.RELEASE' not found.
Tag name: artifactId Description : The unique id for an artifact produced by the project group, e.g. maven-artifact. Version : 3.0.0+ 
<?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.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>springboot-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-demo</name>
    <description>Demo project for Spring Boot</description>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</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>

【问题讨论】:

  • 您是否尝试过在普通命令行上构建。
  • 您是否尝试重新导入项目?右键项目 -> maven -> 重新导入?
  • @khmarbaise 我是 Spring Boot 新手,所以现在不知道如何从命令行构建项目,但过几天会尝试。
  • @Smile 我尝试重新导入项目,但仍然遇到同样的问题。
  • 可以使用命令 mvn clean verify 构建项目,例如在您的终端根目录级别

标签: java spring-boot maven


【解决方案1】:

我遇到了类似的问题。最简单的解决方法是使缓存无效并重新启动

Maven 将在重启后重新同步您的 POM 文件。无需在其他任何地方进行更改。

【讨论】:

  • 这就像一个魅力,但有没有更好的方法?每次添加依赖项时,我都会收到“未找到”错误。我来自 Eclipse,在那里我有 Maven > 从 GUI 更新,这将获得所有依赖项。
  • 嗨@lovrodoe 我不明白你的问题,但我假设你问是否有更好的方法来同步你的 pom 文件添加一个新的依赖项。您可以通过单击右侧的 maven 选项卡并单击 > Reload All Maven Projects 图标(两个圆形箭头)轻松完成此操作。您不必使缓存无效或重新启动。此外,通过单击扳手并选择自动重新加载设置,您可以将项目设置为在进行任何更改后重新加载(如果检测到构建脚本或 pom 文件更改,则自动更新)跨度>
【解决方案2】:

如果无效Caches / Restart... 不起作用,请从“文件-> 设置-> 构建、执行、部署-> 构建工具-> Maven”中检查Always update snapshots。对我来说,工作就像一个魅力。

【讨论】:

    【解决方案3】:

    我遇到了完全相同的问题,然后我找到了解决方法。我不是 Spring Boot 专家,所以我不知道是什么原因造成的,但我可以帮你解决。转到https://start.spring.io/ 然后Click on the add dependencies on the top right corner of the pic. 然后在下拉菜单下选择Spring Web,然后再次生成initializr。

    【讨论】:

      猜你喜欢
      • 2020-08-15
      • 2021-02-26
      • 1970-01-01
      • 2021-03-05
      • 2021-03-29
      • 2018-01-10
      • 1970-01-01
      • 1970-01-01
      • 2023-02-07
      相关资源
      最近更新 更多