spring - 无法使用范围测试的 Maven 依赖项解析 @SpringBootTest

标签 spring spring-boot maven intellij-idea spring-boot-test

我添加了this repositorypom.xml ,但是IntelliJ无法解决org.springframework.boot.test :

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <version>2.2.4.RELEASE</version>
            <scope>test</scope>
        </dependency>

enter image description here

但是,将库添加到 classpath 后,它恰好有效:

enter image description here enter image description here enter image description here

这个存储库有什么特别之处,以至于我应该手动添加它?

编辑:

<scope></scope>导致了这个问题。我不知道它实际上做了什么,它做了 IntelliJ忽略我的main目录。

最佳答案

从本地 Maven 存储库中手动删除它。如果仍然不起作用。将旧版本添加到 pom.xml。 希望能成功

关于spring - 无法使用范围测试的 Maven 依赖项解析 @SpringBootTest,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60331992/

相关文章:

java - 无法处理配置类的导入候选

java - Spring data JPA @Query 与命名列的映射

eclipse - Spring Roo 和 Maven 项目构建生命周期映射

java - ActiveMQQueue 无法解析为 spring-boot-sample 类型

spring - 处理@Configuration 类需要CGLIB

java - Spring Controller 请求资源中点的映射问题

java - Spring-boot:如何配置JMS池连接数

java - bean 类中的属性值在构造函数中为 null

java - 如何在 Spring Boot 中手动启动 Flyway

java - NoClassDefFoundError : org/apache/commons/configuration/ConfigurationException