先来看applicationContext.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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<context:property-place

本文探讨了在Spring中如何使用注解为DAO层装配SessionFactory。提供了两种解决方案:一是设置`default-autowire="byName"`,二是通过在DAO实现类中添加`@Autowired`注解的`mySessionFactory`属性,并在`@PostConstruct`注解的方法中设置。这两种方式都能确保在DAO初始化时正确注入sessionFactory。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



