刚刚发现日志打印出了JDBC Connection will not be managed by Spring,后来看了下,解决问题办法是,spring-context.xml里面不要扫描controller,spring-mvc.xml里面再扫描controller。
spring-context.xml:
<context:component-scan base-package="com.hyoscyami.micromoney"><!-- base-package 如果多个,用“,”分隔 -->
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>spring-mvc.xml:
<context:component-scan base-package="com.hyoscyami.micromoney.web" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
本文介绍了一种解决Spring框架中JDBC连接未被Spring管理的问题的方法。通过调整配置文件spring-context.xml和spring-mvc.xml中的组件扫描设置,确保控制器只在spring-mvc.xml中被扫描,从而避免了JDBC连接管理上的冲突。

被折叠的 条评论
为什么被折叠?



