欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SpringBoot报错:Error starting ApplicationContext. To display the conditions report...........

程序员文章站 2022-07-14 17:06:12
...

Spring Boot启动错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-15 10:07:02.605 ERROR 7064 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.springframework.boot.autoconfigure.dao.PersistenceExceptionTranslationAutoConfiguration.persistenceExceptionTranslationPostProcessor(PersistenceExceptionTranslationAutoConfiguration.java:50)

The following method did not exist:

    org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setProxyTargetClass(Z)V

The method's class, org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor, is available from the following locations:

    jar:file:/C:/Users/Administrator/.m2/repository/org/springframework/spring/2.0.3/spring-2.0.3.jar!/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.class
    jar:file:/C:/Users/Administrator/.m2/repository/org/springframework/spring-tx/5.1.6.RELEASE/spring-tx-5.1.6.RELEASE.jar!/org/springframework/dao/annotation/PersistenceExceptionTranslationPostProcessor.class

It was loaded from the following location:

    file:/C:/Users/Administrator/.m2/repository/org/springframework/spring/2.0.3/spring-2.0.3.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor

2019-05-15 10:07:02.622 ERROR 7064 --- [           main] o.s.test.context.TestContextManager      : Caught exception while allowing TestExecutionListener [or[email protected]1ab3a8c8] to prepare test instance [[email protected]]

原因是在pom文件中导入了2个不同版本的cache依赖,导致依赖冲突

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.0.1</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.springmodules</groupId>
            <artifactId>spring-modules-cache</artifactId>
            <version>0.8</version>
        </dependency>

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


    </dependencies>

删除了后面cache的依赖,问题解决。