#java #spring #spring-session
#java #весна #весенняя сессия
Вопрос:
Я обновляю приложение SpringBoot с 2.1.17 до 2.3.4, которое включает этот класс:
@Configuration
public class SessionRepositoryConfig {
public SessionRepositoryConfig(JdbcOperationsSessionRepository sessionRepo) {
// configure session expiry table name converter
...
...
}
}
Это единственное упоминание JdbcOperationsSessionRepository
во всей базе кода, поэтому, предположительно, в 2.1.17 компонент этого типа был автоматически предоставлен SpringBoot. Однако, когда я переключаюсь на 2.3.4, внедрение завершается неудачно:
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2020-10-13 12:32:43.970 INFO --- [kground-preinit] o.h.v.i.u.Version : HV000001: Hibernate Validator 6.1.2.Final
2020-10-13 12:32:44.082 INFO --- [ main] c.s.o.a.s.UIAuthorizationEndpointTest : Starting UIAuthorizationEndpointTest on UK-WMorgan1 with PID 17444 (started by WMorgan in C:git_reposoauth2-auth-serversc-oauth2-authorization-server-application)
2020-10-13 12:32:44.086 INFO --- [ main] c.s.o.a.s.UIAuthorizationEndpointTest : The following profiles are active: local,dbAutoUpdate,localLDAP
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/C:/Users/wmorgan/.m2/repository/org/codehaus/groovy/groovy/2.5.13/groovy-2.5.13.jar) to method java.lang.Object.finalize()
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClass
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-10-13 12:32:47.823 INFO --- [ main] o.s.b.w.e.t.TomcatWebServer : Tomcat initialized with port(s): 0 (http)
2020-10-13 12:32:47.848 INFO --- [ main] o.a.c.h.Http11NioProtocol : Initializing ProtocolHandler ["http-nio-auto-1"]
2020-10-13 12:32:47.849 INFO --- [ main] o.a.c.c.StandardService : Starting service [Tomcat]
2020-10-13 12:32:47.849 INFO --- [ main] o.a.c.c.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-10-13 12:32:48.046 INFO --- [ main] o.a.c.c.C.[.[.[/oauth2Server] : Initializing Spring embedded WebApplicationContext
2020-10-13 12:32:48.046 INFO --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3561 ms
2020-10-13 12:32:48.444 INFO --- [ main] c.t.c.c.f.KeyStoreFactoryBean : Loading key store from URL [file:./src/test/resources/thunderhead.jks]
2020-10-13 12:32:48.809 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Starting...
2020-10-13 12:32:49.120 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Start completed.
2020-10-13 12:32:50.376 WARN --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepositoryConfiguration' defined in file [C:git_reposoauth2-auth-serversc-oauth2-authorization-server-applicationtargetclassescomSessionRepositoryConfig.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.springframework.session.jdbc.JdbcOperationsSessionRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
2020-10-13 12:32:50.377 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown initiated...
2020-10-13 12:32:50.385 INFO --- [ main] c.z.h.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-10-13 12:32:50.393 INFO --- [ main] o.a.c.c.StandardService : Stopping service [Tomcat]
2020-10-13 12:32:50.410 INFO --- [ main] ConditionEvaluationReportLoggingListener :
Какой самый простой способ заставить это снова работать?
Комментарии:
1. Пожалуйста, добавьте журнал консоли, в котором объясняется основная причина проблемы!
Ответ №1:
Исправлено путем замены JdbcOperationsSessionRepository
на JdbcIndexedSessionRepository