老师我搞不懂这里
<?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:context="http://www.springframework.org/schema/context" 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"> <import resource="spring-dao.xml"></import> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <bean id="orderServiceTarget" class="com.mason.os.service.impl.OrderServiceImpl"></bean> <!--直接配置增强对象 用TransactionProxyFactoryBean--> <bean id="orderService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <!--设置事务管理器--> <property name="transactionManager" ref="transactionManager"></property> <!--配置事务属性--> <property name="transactionAttributes"> <props> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="search*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="*">PROPAGATION_REQUIRED</prop> </props> </property> <!--配置目标类--> <property name="target" ref="orderServiceTarget"></property> </bean> </beans>

这里的key
get* find* search* 还有最后一个 *
都是指什么?
如果是指方法名的话,哪里有这些方法?
15
收起
正在回答
2回答
同学你好!
tx里面配置的是方法的事务,后面的*是通配符,意思是凡是方法名以get或者find和search开头的都支持当前事务,如果当前没有事务,就新建一个事务。最后一个*表示所有,老师这里并没有将所有的方法都写全,只是做了一个演示呢

这里是配置哪些类要添加切面(配置事是通过包名.类名的方式,*表示所有)

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
MasonM
2019-07-24 15:36:19

这个也是一样,我也搞不懂,在
package com.mason.os.service.impl;
import com.mason.os.dao.OrderDao;
import com.mason.os.dao.ProductDao;
import com.mason.os.entity.Order;
import com.mason.os.entity.Product;
import com.mason.os.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import java.util.Date;
@Service
public class OrderServiceImpl implements OrderService {
@Autowired
private OrderDao orderDao;
@Autowired
private ProductDao productDao;
public void addOrder(Order order) {
order.setCreateTime(new Date());
order.setStatus("待付款");
orderDao.insert(order);
Product product = productDao.select(order.getProductsId());
product.setStock(product.getStock() - order.getNumber());
productDao.update(product);
}
}中根本就没有以那些开头的方法呀
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程


恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星