【发布时间】:2019-09-17 22:01:55
【问题描述】:
我在 IntelliJ 中的 maven 依赖项版本更改方面一直存在问题。每当我尝试使用以前版本的库并更改 pom.xml 中的依赖项版本时,什么都没有发生。 Maven 继续使用更新版本的库。
例如我想用:
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
但 Maven 存储库已保存 2.0.2 版:
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.0.2.RELEASE</version>
</dependency>
所以对于我的项目,使用的是 2.0.2.RELEASE 版本。
我先尝试重新导入项目。然后我尝试“重新导入所有 Maven 项目”。然后我检查了 Settings > Maven > Always update snapshots。我还尝试打开项目设置并从那里删除依赖项,但是在重新导入时,2.0.2 版本将被导入项目中。目前唯一可行的方法是从“.m2”文件夹中手动删除该文件夹。
不应该严格遵循库版本,不应该将 2.0.1 v 版本用于我的项目吗?
【问题讨论】:
-
也许 IntelliJ 正在缓存您的依赖项。我遇到了很多问题,解决问题的方法是通过
File->Invalidate Caches / Restart清理缓存
标签: maven intellij-idea