【问题标题】:Missing maven dependencies although dependencies exist in pom.xml尽管 pom.xml 中存在依赖项,但缺少 maven 依赖项
【发布时间】:2021-11-23 08:23:26
【问题描述】:

当我添加依赖项时,Maven 依赖项中不存在一个依赖项(spring-context),如下所示:

到目前为止我所做的是:

项目 -> 清理 Maven ->更新 Maven 项目

并应用了这些步骤:

https://stackoverflow.com/a/9761685/12100307

pom.xml:

...<dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>5.3.10</version>
            <type>module</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>5.3.10</version>
            <type>module</type>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context  </artifactId>
            <version>5.3.10</version>
            <type>module</type>
        </dependency>
    </dependencies>...

【问题讨论】:

  • 这件事一直发生在我身上,大多数时候是 IDE 缓存的问题。我不知道如何在 Eclipse 中做到这一点,但在 intellij 中你可以简单地 invalidate caches and restart.
  • &lt;type&gt;module&lt;/type&gt; 是什么?删除它......并在普通命令上重建......

标签: java spring maven dependencies spring-framework-beans


【解决方案1】:

经过一些 .m2 clean, dependency clean, maven -> update project etc. reindexing etc. 问题通过如下更新 pom.xml 得到解决:

希望对你也有帮助!

... <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
        <spring.version>5.0.2.RELEASE</spring.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
    </dependencies>
...

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2018-09-20
  • 2019-04-09
  • 1970-01-01
  • 2018-11-11
  • 2014-02-19
  • 2011-05-14
  • 2012-03-30
  • 2014-06-10
相关资源
最近更新 更多