设为首页 加入收藏

TOP

spring5随笔(十一)
2023-07-25 21:42:39 】 浏览:100
Tags:spring5 随笔
a/beans/spring-beans.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-tx.aop"> <!--data source--> <bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://111.230.212.103:3306/mybatis?userSSL=true&amp; userUnicode=true&amp;characterEncoding=UTF-8"/> <property name="username" value="root"/> <property name="password" value="hdk123"/> </bean> <!--sqlsession--> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="datasource" /> <!--bound mybatis--> <property name="configLocation" value="classpath:mybatis-config.xml"/> <property name="mapperLocations" value="classpath:com/mapper/*.xml"/> </bean> <!--声明式事务--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <constructor-arg ref="datasource" /> </bean> <!--结合aop实现事务置入--> <!--配置事务的类--> <tx:advice id="tx1" transaction-manager="transactionManager"> <!--给哪些方法配置事务--> <!--配置事务的传播特性--> <tx:attributes> <tx:method name="add" propagation="REQUIRED"/> <tx:method name="delete" propagation="REQUIRED"/> <tx:method name="update" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED"/> <tx:method name="query" read-only="true"/> </tx:attributes> </tx:advice> <!--配置事务切入--> <aop:config> <aop:pointcut id="txpointxut" expression="execution(* com.mapper.*.*(..))"/> <aop:advisor advice-ref="tx1" pointcut-ref="txpointxut"/> </aop:config> </beans> <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd"> <import resource="spring-dao.xml"/> <bean id="userMapper2" class="com.mapper.UserMapperIml2"> <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> </bean> </beans>

Mapper

package com.ws.mapper;

import com.ws.pojo.User;

import java.util.List;

public interface UserMapper {
    List<User> sel
首页 上一页 8 9 10 11 下一页 尾页 11/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇98%的程序员,都没有研究过JVM重.. 下一篇springboot01

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目