解決 Connection is not transactional
来源:互联网 发布:网络推广专员 编辑:程序博客网 时间:2024/05/02 04:40
在项目开发中遇到这个异常Exception in thread "main" java.lang.IllegalStateException: Connection is not transactional,仔细的百度了一下,发现大多数的任都说是在查询之前没有connect数据库。但是我认真地分析了一下原因,发现问题的根源在于我的beans.xml没有将Connect加进事务管理。
解决方法,在beans.xml加进事务管理。
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd"
>
<context:component-scan base-package="com.haiminhuang.test"/>
<context:property-placeholder location="classpath:sys.properties"/>
<context:annotation-config/>
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.user}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="30" />
<property name="initialSize" value="5" />
<property name="maxWait" value="300" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
</beans>
需要注意的是以下的这一句:
Can not set field to $Proxy异常。
0 0
- 解決 Connection is not transactional
- HikariCP - connection is not available
- AS connection is not connect
- 解决Smack 提示“ Connection is not authenticated”
- 火狐浏览器:This Connection is not Secure
- Spring @transactional not working
- ORA-01090: shutdown in progress - connection is not permitted
- ORA-01090: shutdown in progress - connection is not permitted
- ORA-01090: shutdown in progress - connection is not permitted
- ORA-01090 shutdown in progress - connection is not permitted
- ORA-01090: shutdown in progress - connection is not permitted
- The Managed Metadata Service or Connection is currently not available
- ORA-01090: shutdown in progress - connection is not permitted
- ORA-01090: shutdown in progress - connection is not permitted
- Mac DBeaver Client home is not specified for connection解决办法
- chrome 出现:Your connection is not private NET::ERR_CERT_WEAK_SIGNATURE_ALGORITHM
- firefox火狐 "Your connection is not secure" "Secure Connection Failed" 问题解决
- The specified named connection is either not found in the configuration, not intended to be used
- 【自考】数据结构导论
- Redis之实战篇(与Mybatis整合)
- QT 线程池 + TCP 小试(二)实现通信功能
- adb常用命令
- 汇编第一步--入门
- 解決 Connection is not transactional
- 转android-Service和Thread的区别
- Notes: scanf dead lock problem and rand() in C
- 设计模式学习之路-备忘录模式
- leetCode No.152 Maximum Product Subarray
- 如何将卫星影像进行投影转换转换成北京54坐标
- QT 线程池 + TCP 小试(三)实现最终功能
- 实现按照字母分类分组排序
- Java字符串处理的一些问题