- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Spring Transaction 不适用于使用 TOMCAT 的以下配置。
spring: version: 3.1.2.RELEASE
spring.ws:version:2.0.5.RELEASE
Mybatis: version:3.1.1
Database: Oracle 11g
Datasource connection:com.oracle.ojdbc6.11.2.0
Server : Tomcat : apache-tomcat-6.0.32
我们正在尝试使用 AOP 声明式事务实现来创建事务服务。该设置工作正常,在集成测试期间按预期创建事务,但在使用端点从 SoapUi 运行测试时,在本地服务器(Tomcat)上,所有事务都是非事务性的(可以在日志文件中看到相同的)
SPRING-DAOS.xml
xml version="1.0" encoding="UTF-8"
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
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-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<!-- enable the configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="mywebappActiveTransactionManager" />
<aop:aspectj-autoproxy/>
<!-- ensure that the above transactional advice runs for any execution
of an operation defined by the Service interface -->
<aop:config>
<aop:pointcut id="transactionalOperation" expression="execution(* com.org1.org2.mywebappgate.services.*.*(..)) "/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="transactionalOperation"/>
</aop:config>
<!-- the transactional advice (what 'happens'; see the <aop:advisor/> bean below) -->
<tx:advice id="txAdvice" transaction-manager="mywebappActiveTransactionManager">
<tx:attributes>
<tx:method name="*" rollback-for="SQLException"/>
<!-- <tx:method name="*" read-only="false" propagation="REQUIRED" /> -->
<!-- <tx:method name="*" read-only="false" propagation="REQUIRED" /> -->
</tx:attributes>
</tx:advice>
<jee:jndi-lookup id="mywebappActiveDataSource" jndi-name="java:/comp/env/jdbc/mywebapp-active" />
<bean id="mywebappActiveTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="mywebappActiveDataSource" />
</bean>
<bean id="mywebappActiveSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="mywebappActiveDataSource" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>
<bean id="mywebappActiveMapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.org1.org2.mywebappgate.dao" />
<property name="sqlSessionFactoryBeanName" value="mywebappActiveSessionFactory" />
</bean>
Tomcat 上下文.xml
<Context>
<!-- Default set of monitored resources -->
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver" maxActive="20" maxIdle="10" maxWait="-1" name="jdbc/mywebapp-active" password="xxxxxx" type="javax.sql.DataSource" url="jdbc:oracle:thin:@mywebappdc1.company:1521:mywebappdc1" username="xxxxxx"/>
mybatis-config.xml
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- changes from the defaults -->
<setting name="lazyLoadingEnabled" value="false" />
</settings>
<mappers>
<mapper resource="company/mywebappgate/dao/SimpleCommentDao.xml" />
<mapper resource="company/mywebappgate/dao/CommentDao.xml"/>
<mapper resource="company/mywebappgate/dao/ARDAO.xml"/>
<mapper resource="company/mywebappgate/dao/ASIndicatorsDao.xml"/>
</mappers>
Junit 测试日志:
org.mybatis.spring.SqlSessionUtils: Creating a new SqlSession
org.mybatis.spring.SqlSessionUtils: Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@c3c44]
org.mybatis.spring.transaction.SpringManagedTransaction: JDBC Connection [oracle.jdbc.driver.T4CConnection@1d5d765] will be managed by Spring
org.mybatis.spring.SqlSessionUtils: Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@c3c44]
org.mybatis.spring.SqlSessionUtils: Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@c3c44] from current transaction
org.mybatis.spring.SqlSessionUtils: Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@c3c44]
org.mybatis.spring.SqlSessionUtils: Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@c3c44]
org.springframework.context.support.GenericApplicationContext: Closing org.springframework.context.support.GenericApplicationContext@1b4fad5: startup date [Wed Sep 05 14:16:30 EDT 2012]; root of context hierarchy
org.springframework.beans.factory.support.DefaultListableBeanFactory: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@69d02b: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionalOperation,org.springframework.aop.support.DefaultBeanFactoryPointcutAdvisor#0,txAdvice
Tomcat 日志:
org.mybatis.spring.SqlSessionUtils: Creating a new SqlSession
org.mybatis.spring.SqlSessionUtils: SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e55d39] was not registered for synchronization because synchronization is not active
org.mybatis.spring.transaction.SpringManagedTransaction: JDBC Connection [jdbc:oracle:thin:@mywebapp1.company:1521:mywebapp1, UserName=user, Oracle JDBC driver] will not be managed by Spring
org.mybatis.spring.SqlSessionUtils: Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1e55d39]
org.mybatis.spring.SqlSessionUtils: Creating a new SqlSession
org.mybatis.spring.SqlSessionUtils: SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@5b02a6] was not registered for synchronization because synchronization is not active
org.mybatis.spring.transaction.SpringManagedTransaction: JDBC Connection [jdbc:oracle:thin:@mywebappdc1.company:1521:mywebappdc1, UserName=mywebappSOA01, Oracle JDBC driver] will not be managed by Spring
最佳答案
如果您使用的是 Spring,则无需在 mybatis-*.xml 中配置 xml。您只需要在 mywebappActiveSessionFactory 中包含一个属性:
<property name="mapperLocations"
value="classpath*:company/mywebappgate/dao//*Mapper.xml"/>
你的 mybatis-config.xml 将是
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<!-- changes from the defaults -->
<setting name="lazyLoadingEnabled" value="false" />
</settings>
关于Spring Mybatis Tomcat - 不使用 Spring 的事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12302598/
1.概述 转载:MyBatis 二级缓存全详解 上一篇文章中我们介绍到了 MyBatis 一级缓存其实就是 SqlSession 级别的缓存,什么是 SqlSession 级别的缓存呢?一级缓存的本质
1.概述 转载:核心配置综述之StatementHandler 2.MyBatis 四大组件之StatementHandler StatementHandler 是四大组件中最重要的一个对象,负责操作
1.概述 转载:MyBatis 启动流程 MyBatis 是第一个支持自定义 SQL、存储过程和高级映射的类持久框架。MyBatis 消除了大部分 JDBC 的样板代码、手动设置参数以及检索结果。My
1.概述 转载:MyBatis 基础搭建及架构概述 2.MyBatis 是什么? MyBatis是第一个支持自定义SQL、存储过程和高级映射的类持久框架。MyBatis消除了大部分JDBC的样板代码、
1.概述 转载:核心配置综述之 ParameterHandler MyBatis 四大核心组件我们已经了解到了两种,一个是 Executor ,它是MyBatis 解析SQL请求首先会经过的第一道关卡
1.概述 转载:核心配置综述之 ResultSetHandler 我们之前介绍过了MyBatis 四大核心配置之 Executor、StatementHandler、 ParameterHandler
如果我使用mybatis,我可以很容易地得到更新的行数,就像 update table set desc = 'xxx' where name = ? 但是,如果我想获取更新的行数,而不是计数,我该如
如何在MyBatis 3中使用小于等于 SELECT * FROM( SELECT * FROM TABLE1 WHERE COL1 =#{COL1,jdbc
我将 mybatis3.0.6 与 java 一起使用 哪个性能更好? [select id="getData" parameterType="Integer" resultType="Integer
我无法在 mybatis 中使用动态排序类型创建 SQL,如下例 select user_profile.user_profile_id, user_profile.first_name
这是一个流行的例子。 insert into ACCOUNT ( ACC_ID, ACC_FIRST_NAME, ACC_LAST_NAME, ACC_EMAIL )values (
我下载了MyBatis,文件夹中有一个mybatis-3.0.4-javadoc.jar,我解压并打开它,但它几乎是空的。 哪里可以找到MyBatis的API文档? 最佳答案 http://repo1
我正在尝试为 ArrayList 编写类型处理程序,但这给了我错误,任何人都可以帮助我。 我想将 ArrayList 作为 VARCHAR 存储在数据库中并将其检索为 ArrayList。 packa
目录 依赖 配置 CodeGenerator mybatis-plus-generator + clickhouse 自动生成代码 依赖
目录 三者实现对比 使用fluent mybatis 来实现上面的功能 换成mybatis原生实现效果 换成mybatis plus
例如,我有查询从员工中选择 ID、姓名、年龄、地址,而不是拥有员工对象列表。我希望有一个 map 列表,如 list{ map{ ("id", 123), ("name","jac
我在使 MyBatis (3.4.6) 工作时遇到一些麻烦。 我已将 mybatis-config.xml 文件放置在项目的 src/main/resources 文件夹中,但是当我运行单元测试时,出
我现在使用 Mybatis 和 spring-boot。我没有添加mybatis-config.xml。我根据说明通过 application.properties 为数据源和 mybatis 进行所
这是我的第一篇文章,用我糟糕的英语...... 我使用的是MyBatis3.0 在查询中,我使用 SqlBuilder 的方法如下: public class DataStatisticSqlBuil
主题:MyBatis:Boolean Paraeter:MyBatis 正在使用 Getter 内容: 大家好, 我一直在寻找解决我近乎简单的 MyBatis 问题的方法: 给定代码(仅必要部分):
我是一名优秀的程序员,十分优秀!