【问题标题】:class path resource [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.class] cannot be opened because it does not exist类路径资源 [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.class] 无法打开,因为它不存在
【发布时间】:2019-07-20 17:29:09
【问题描述】:

我在 IntelliJ 上关注 https://spring.io/guides/gs/accessing-data-mysql/。 但是在我执行 spring-boot:run 命令后,会发生以下错误

org.springframework.beans.factory.BeanDefinitionStoreException:无法处理配置类 [org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration$WebFluxConfig] 的导入候选;嵌套异常是 java.io.FileNotFoundException: 类路径资源 [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.class] 无法打开,因为它不存在

我完全遵循官方指南。那么我错过了什么?

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>nathan</groupId>
        <artifactId>accessing-data-mysql</artifactId>
        <version>1.0-SNAPSHOT</version>

        <parent>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>2.1.3.RELEASE</version>
        </parent>

        <dependencies>
                <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-web</artifactId>
                        <version>2.1.3.RELEASE</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-jpa</artifactId>
                        <version>2.1.3.RELEASE</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
                <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.15</version>
                </dependency>
                <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
                <dependency>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.6</version>
                        <scope>provided</scope>
                </dependency>
                <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-test</artifactId>
                        <version>2.1.3.RELEASE</version>
                        <scope>test</scope>
                </dependency>

                <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-couchbase -->
                <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-data-couchbase</artifactId>
                        <version>2.1.3.RELEASE</version>
                </dependency>

            <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-web</artifactId>
                        <version>5.1.5.RELEASE</version>
                </dependency>

        </dependencies>
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                <artifactId>spring-boot-maven-plugin</artifactId>
                        </plugin>
                </plugins>
        </build>

</project>

application.properties

spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/db_example
spring.datasource.username=spring_user
spring.datasource.password=123456789

【问题讨论】:

  • 能否分享完整的 pom.xml 和属性文件?
  • 尝试使用相同的依赖项进行复制,它对我有用,您可以尝试重新创建项目
  • 请不要将 XML 作为图像发布,使用正确的标签并改用文本。目前它完全不可读。
  • @BalajiSrinivasan 更新 pom 和属性,谢谢
  • 从依赖项中删除 &lt;version&gt; 并删除 spring-web 依赖项,这已经是您包含的 spring-boot-starter-web 的一部分。

标签: spring-boot


【解决方案1】:

我认为你的主类是错误的,你正在使用这样的东西:

SpringApplication.run(SpringBootApplication.class);

请确保在您的主类上调用SpringApplication.run() 方法(以下示例中的MainApplication):

@SpringBootApplication
public class MainApplication{

    public static void main(String[] args){
        SpringApplication.run(MainApplication.class, args);
    }
}

【讨论】:

  • 我面临与@nathan 相同的问题,但在我的情况下,该错误肯定与错误的 Spring Boot 主类无关。我在使用 @SpringBootTest(classes = SpringBootApplication.class, webEnvironment = WebEnvironment.MOCK) 运行 JUnits 时看到错误
猜你喜欢
  • 1970-01-01
  • 2012-01-01
  • 1970-01-01
  • 2016-12-01
  • 2020-10-21
  • 2015-03-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多