首页 > 解决方案 > 类路径资源 [org/springframework/web/reactive/config/DelegatingWebFluxConfiguration.class] 无法打开,因为它不存在

问题描述

我 在 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>

应用程序属性

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

标签: spring-boot

解决方案


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

SpringApplication.run(SpringBootApplication.class);

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

@SpringBootApplication
public class MainApplication{

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

推荐阅读