【问题标题】:Dependency 'org.springframework.boot:spring-boot-starter-security:2.2.6.RELEASE' not found未找到依赖项 'org.springframework.boot:spring-boot-starter-security:2.2.6.RELEASE'
【发布时间】:2020-08-15 15:27:04
【问题描述】:

我是 Spring 新手,所以如果你们中的任何人能在这方面帮助我,我将不胜感激。我正在使用当前版本 2.2.6.RELEASE 添加 spring-boot-starter-security 的依赖项,并且我的父母也具有相同的版本。但仍然出现错误-

Dependency 'org.springframework.boot:spring-boot-starter-security:2.2.6.RELEASE' not found .Tag name: artifactId Description : 项目组生成的工件的唯一 ID,例如Maven 神器。版本: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.2.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.arpita</groupId>
    <artifactId>security_first</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>security_first</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>2.2.6.RELEASE</version>
        </dependency>

【问题讨论】:

  • 尝试从 maven 本地 repo 中删除 .m2/or.springframework/ 并通过 mvn clean install 重新导入所有内容
  • 并且没有必要定义spring-boot-starter-security&lt;version&gt;,因为你使用spring-boot-starter-parent作为父pom。
  • 尝试运行命令mvn clean install -U
  • 非常感谢它的帮助!删除 .m2 存储库和 mvn clean install 帮助我的应用程序运行良好。

标签: java spring spring-boot maven


【解决方案1】:

您不需要提及版本,但这取决于。您的 spring boot parens 可以有比您指定的旧版本或新版本。如果您指定旧版本,则不会编译。 Erwin Smith 写了 file -> invalidate caches/restart 并且它会起作用。这对我有用,但如果情况如我所写,则无法帮助您。检查您的父 pom 中的版本是否较新,使缓存无效/重新启动,否则将版本更新为较新的版本,它应该可以工作。

【讨论】:

    【解决方案2】:

    文件 -> 使缓存无效/重新启动,它将起作用。

    【讨论】:

      【解决方案3】:

      我的建议是自己安装 maven。 我有时也有同样的问题。我认为这是因为 Intellij。所以我关闭了这个项目,这是一个简单的 spring boot 项目,由 Intellij 自己学习和安装 maven。在窗口 10 中配置环境变量后,我重新打开项目,现在一切正常。

      【讨论】:

        【解决方案4】:

        您无需提及spring boot会处理的spring boot项目的版本 添加以下依赖项

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

        最后,更新你的项目

        【讨论】:

          【解决方案5】:

          顺便说一句,您不需要为 starter POM 指定版本。如果您从 security starter 中删除版本标签,它应该可以正常工作。

          【讨论】:

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