【问题标题】:Why is IntelliJ adding wrong maven dependency in my Spring Boot project?为什么 IntelliJ 在我的 Spring Boot 项目中添加了错误的 Maven 依赖项?
【发布时间】:2019-10-07 06:02:01
【问题描述】:

当我在 RequestMapping 显示的弹出窗口中单击导入 maven 依赖项时,intellij 会添加

<dependency>
    <groupId>org.springframework</groupId>   
    <artifactId>spring-web</artifactId>
    <version>5.1.10.RELEASE</version>
</dependency>

但它应该添加这个。

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

我该如何解决这个问题?我已经为 maven 启用了自动导入,并且我已经尝试了带有 IntelliJ 的 maven 捆绑版本和手动下载的版本。 手动更改依赖项使程序正常运行。

【问题讨论】:

  • 它将找到包含该类的依赖项。这是spring-web 而不是spring-boot-starter-web(因为后者只是一个包含其他依赖项的BOM)。
  • 一切正常。 Spring Boot Starter 依赖项旨在手动添加或使用 start.spring.io。
  • @M.Deinum 我在哪里可以找到更多关于他们的信息?

标签: maven spring-boot intellij-idea


【解决方案1】:

打开pom.xml

删除以下依赖:

<dependency>
    <groupId>org.springframework</groupId>   
    <artifactId>spring-web</artifactId>
    <version>5.1.10.RELEASE</version>
</dependency>

并添加:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-27
    • 2020-09-22
    • 1970-01-01
    • 2019-03-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多