将 JdbcOperationsSessionRepository 注入构造函数
Injecting JdbcOperationsSessionRepository into a constructor
我正在将 SpringBoot 应用程序从 2.1.17 升级到 2.3.4,其中包括 class:
@Configuration
public class SessionRepositoryConfig {
public SessionRepositoryConfig(JdbcOperationsSessionRepository sessionRepo) {
// configure session expiry + table name + converter
...
...
}
}
这是整个代码库中仅提及JdbcOperationsSessionRepository
的地方,因此大概在 2.1.17 中,SpringBoot 自动提供了这种类型的 bean .但是,当我切换到 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_repos\oauth2-auth-server\sc-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_repos\oauth2-auth-server\sc-oauth2-authorization-server-application\target\classes\com\SessionRepositoryConfig.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 :
让我重新开始工作的最简单方法是什么?
已通过将 JdbcOperationsSessionRepository
替换为 JdbcIndexedSessionRepository
来修复
我正在将 SpringBoot 应用程序从 2.1.17 升级到 2.3.4,其中包括 class:
@Configuration
public class SessionRepositoryConfig {
public SessionRepositoryConfig(JdbcOperationsSessionRepository sessionRepo) {
// configure session expiry + table name + converter
...
...
}
}
这是整个代码库中仅提及JdbcOperationsSessionRepository
的地方,因此大概在 2.1.17 中,SpringBoot 自动提供了这种类型的 bean .但是,当我切换到 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_repos\oauth2-auth-server\sc-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_repos\oauth2-auth-server\sc-oauth2-authorization-server-application\target\classes\com\SessionRepositoryConfig.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 :
让我重新开始工作的最简单方法是什么?
已通过将 JdbcOperationsSessionRepository
替换为 JdbcIndexedSessionRepository