java - 创建类路径资源中定义的名称为 'sessionRepositoryFilterRegistration' 的 bean 时出错

标签 java spring jpa gradle entity

执行spring后出现错误。请告诉我如何解决它。 我需要你的帮助。

错误

2019-01-22 20:23:25.416  INFO 8692 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 19145 ms
    2019-01-22 20:23:25.759 ERROR 8692 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'sessionRepositoryFilterRegistration' defined in class path resource [org/springframework/boot/autoconfigure/session/SessionRepositoryFilterConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepositoryFilterRegistration' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration': Injection of autowired dependencies failed; nested exception is java.lang.NoSuchMethodError: org.springframework.boot.autoconfigure.session.RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.setCleanupCron(Ljava/lang/String;)V
    2019-01-22 20:23:25.839  WARN 8692 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    :bootRun FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':bootRun'.
    > Process 'command 'C:\Program Files\Java\jdk1.8.0_121\bin\java.exe'' finished with non-zero exit value 1

build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容build.gradle 内容

buildscript {

    ext {
        springBootVersion = '2.0.0.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE")
    }
}

apply plugin: 'java'

apply plugin: 'eclipse'

apply plugin: 'org.springframework.boot'


group = 'com.example'

version = '0.0.1-SNAPSHOT'

sourceCompatibility = 1.8

repositories {

    mavenCentral()

    maven {

        url 'https://jitpack.io'

    }
}

dependencies {
    compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.46'

    compile('org.springframework.boot:spring-boot-starter-data-jpa:2.0.0.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-web:2.0.0.RELEASE')
    compile('javax.validation:validation-api:2.0.0.Final')
    compile('org.apache.commons:commons-lang3:3.6')
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.2.14.Final'
    compile files('lib/gsf-3.0.jar')

    // new
    compile ('com.voodoodyne.jackson.jsog:jackson-jsog:1.0')
    compile('org.springframework.boot:spring-boot-starter-security:2.0.0.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-thymeleaf:2.0.0.RELEASE')
    compile('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:2.3.0')
    compile ('com.google.guava:guava:23.3-jre')
    compile('org.springframework.session:spring-session:1.3.1.RELEASE')
    compile('org.springframework.session:spring-session-data-redis:1.3.1.RELEASE')
    compile('org.glassfish:javax.el:3.0.1-b08')
    compile("com.querydsl:querydsl-core:4.1.4")
    compile("com.querydsl:querydsl-jpa:4.1.4")
    compile("com.querydsl:querydsl-apt:4.1.4")
    compile('org.springframework.data:spring-data-redis:2.0.5.RELEASE')
    compile('org.springframework.data:spring-data-jpa:2.0.5.RELEASE')
    compile('org.springframework.security.oauth:spring-security-oauth2:2.3.3.RELEASE')

    compile('org.springframework.security:spring-security-core:5.0.3.RELEASE')
    compile('com.squareup.okhttp3:okhttp:3.8.0')
    compile('com.squareup.retrofit2:retrofit:2.3.0')
    compile('com.github.iamport:iamport-rest-client-java:0.1.10')
    compile('com.alibaba:fastjson:1.2.47')
    compile ('org.json:json:20180813')
    compile ('org.apache.xmlgraphics:batik-transcoder:1.7')
    compile('org.springframework:spring-test:2.5')
    compile('commons-validator:commons-validator:1.6')

    runtime('mysql:mysql-connector-java')
    compileOnly('org.projectlombok:lombok:1.16.20')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

最佳答案

添加以下依赖项帮助我解决了上述问题。

compile "org.springframework.session:spring-session-data-redis:2.0.3.RELEASE"

关于java - 创建类路径资源中定义的名称为 'sessionRepositoryFilterRegistration' 的 bean 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54313238/

相关文章:

java - 圆环图 Apache-POI

java - 有什么方法可以从字节码重新生成堆栈图?

spring - 获取异常 : No bean named 'springSecurityFilterChain' is defined

java - 为什么 jpa2/eclipselink 不生成删除级联 SQL?

java - 如何在 spring jpa 中运行没有事务的更新/删除操作

java - JFrame setBackground 的目的是什么

java - 如何在python中定义引用同一类对象的类变量

spring - 在 Grails 中使用 AOP 不适用于服务

java - 在 Spring 中,直接从服务返回 ResponseEntity 是更好的做法还是应该在 Controller 内创建它?

java - JPA - 如何映射到快速查找表?