框架——(配合mvc)spring(配置xml)
分类:
文章
•
2024-05-11 10:26:10
第一步,扫描带注解的类(扫描这个包)**注解(不能**@Service、@Controller、@Component等则不行,需要在mvc里配置)
指定属性文件的位置(里面专门放置了jdbc数据源的配置和hibernate的配置)
Bean配置数据源(引入属性文件的配置${})
配置sessionfactory工厂(在里面**数据源,扫描带@entity注解的包,配置hibernate)
Bean配置org.springframework.orm.hibernate5.HibernateTransactionManager,将sessionfactory纳入事务
使用annotation定义事务<tx:annotation-driven transaction-manager="transactionManager"/>