Spring会话JdbcHttpSessionConfiguration导致JPA bean无法启动
我正在尝试使用Spring会话和PostgreSQL来存储http会话 这是我的XMLSpring会话JdbcHttpSessionConfiguration导致JPA bean无法启动,spring,spring-jdbc,spring-session,Spring,Spring Jdbc,Spring Session,我正在尝试使用Spring会话和PostgreSQL来存储http会话 这是我的XML <context:annotation-config/> <bean class="org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration"/> <bean id="dataSource" class="org.springframework.jdbc
<context:annotation-config/>
<bean class="org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration"/>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"></property>
<property name="url" value="jdbc:postgresql://127.0.0.1:5432/myapp"></property>
<property name="username" value="postgres"></property>
<property name="password" value=""></property>
</bean>
<bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<constructor-arg ref="dataSource"/>
我的应用程序已经在使用SpringJPA进行其他DB操作。但问题是在我添加了
<context:annotation-config/>
<bean class="org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration"/>
启动时未加载我的JPA bean,因此应用程序未启动。我尝试了以下步骤
我在卡塔琳娜没有犯任何错误。因此,将try-catch放在我的应用程序中,它尝试获取jpabean。我收到以下错误。
找不到bean的类[org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration] 名称为“org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration#0” 在类路径资源[applicationContext_Web.xml]中定义;嵌套异常为java.lang.ClassNotFoundException: org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration pom中添加的依赖项
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-jdbc</artifactId>
<version>2.0.4.RELEASE</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.0.7.RELEASE</version>
</dependency>
org.springframework.session
春季会话jdbc
2.0.4.1发布
聚甲醛
org.springframework
弹簧网
5.0.7.发布
我可以解决它。不知何故,maven仍然选择spring会话核心jar而不是spring会话jdbc。我刚刚删除了pom,再次进行了maven更新。不确定是如何使用正确的连接的。如果您已经配置了DB连接,那么您就不必再这样做了。我想我已经尝试过了。未在此XML中指定任何数据源,并希望会话JDBC获取另一个用于JPA连接的XML中提到的datosource。还将id指定为“数据源”。我还遗漏了什么?发布错误。我在catalina.out中没有发现任何错误。因此,将try-catch放在我的应用程序中,它尝试获取jpabean。我得到以下错误。找不到在类路径资源[applicationContext_web.xml]中定义的名为“org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration”的bean的类[org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration];嵌套异常是java.lang.ClassNotFoundException:org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration