使用spring.test+junit4测试的时候
在service保存的时候泛型DAO报错:错误指向--->getHibernateTemplate().save(entity);
可以确定entity参数值为非空,不知道错在哪里?
GenericHibernateDao.save方法为
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
getHibernateTemplate().save(entity);
}
java.lang.NullPointerException
at com.postek.dsmis.common.util.hibernate.GenericHibernateDao.save(GenericHibernateDao.java:95)
at com.postek.dsmis.inner.daoImpl.InnerUserDaoImpl.addNerInnerUser(InnerUserDaoImpl.java:16)
at com.postek.dsmis.inner.serviceImpl.InnerUserServiceImpl.addNewInnerUser(InnerUserServiceImpl.java:32)
at com.postek.dsmis.inner.serviceImpl.TestSpring.addNewUser(TestSpring.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
----------------------------------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:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!-- 用注解方式注入bean -->
<context:annotation-config />
<context:component-scan base-package="com.postek.dsmis" />
<!-- 数据库连接池 -->
<bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">
<property name="driver">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="driverUrl">
<value>jdbc:mysql://localhost:3306/drpis?useUnicode=true&characterEncoding=utf-8</value>
</property>
<!-- 最好不配置在user与password里面 -->
<property name="user">
<value>root</value>
</property>
<property name="password">
<value>123</value>
</property>
<property name="alias">
<value>drpis</value>
</property>
<property name="prototypeCount">
<value>5</value>
</property>
<property name="maximumConnectionCount">
<value>30</value>
</property>
<property name="minimumConnectionCount">
<value>5</value>
</property>
<property name="maximumActiveTime">
<value>10000</value>
</property>
<property name="trace">
<value>true</value>
</property>
<property name="verbose">
<value>true</value>
</property>
</bean>
<!-- dbcp数据库连接池 <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"> <property name="driverClassName" value="com.mysql.jdbc.Driver"
/> <property name="url" value="jdbc:mysql://localhost:3306/drpis?useUnicode=true&characterEncoding=UTF-8"
/> <property name="username" value="root" /> <property name="password" value="123"/>
</bean> -->
<!-- hibernate sessionFactory 创建 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.postek.dsmis.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">validate</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
</props>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- <bean id="GenericHibernateDao" class="com.postek.dsmis.common.util.hibernate.GenericHibernateDao">
<property name="sessionFactory" ref="sessionFactory"></property> </bean> -->
<!-- 事物配置 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="find*" read-only="true" />
<tx:method name="get*" read-only="true" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="set*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="create*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut
expression="execution(public * com.postek.dsmis..serviceImpl..*.*(..))"
id="myPointcut" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="myPointcut" />
</aop:config>
</beans>
9 个解决方案
#1
注入对了没有啊 ?
#2
通用泛型DAO,GenericHibernateDao.save方法为:
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
getHibernateTemplate().save(entity);
}
----------------------测试代码-----------------------------
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class TestSpring extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void addNewUser() throws NoSuchAlgorithmException {
InnerUserServiceImpl impl = new InnerUserServiceImpl();
InnerUser innerUser = new InnerUser();
innerUser.setDepartmentId("1");
innerUser.setDepartmentName("信息");
innerUser.setLastloginAdrees(null);
innerUser.setLastLoginIp(null);
innerUser.setLastloginTime(null);
innerUser.setName("系统管理员");
innerUser.setUsername("admin");
innerUser.setPassword(new EncryptionMD5().getModifyMD5("admin"));
innerUser.setPosition("信息工程师");
innerUser.setTel("13632657240");
innerUser.setUseable("1");
impl.addNewInnerUser(innerUser);
}
}
使用spring.test+junit4测试的时候
在service保存的时候泛型DAO报错:错误指向--->getHibernateTemplate().save(entity);
提示空指针
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
getHibernateTemplate().save(entity);
}
----------------------测试代码-----------------------------
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class TestSpring extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void addNewUser() throws NoSuchAlgorithmException {
InnerUserServiceImpl impl = new InnerUserServiceImpl();
InnerUser innerUser = new InnerUser();
innerUser.setDepartmentId("1");
innerUser.setDepartmentName("信息");
innerUser.setLastloginAdrees(null);
innerUser.setLastLoginIp(null);
innerUser.setLastloginTime(null);
innerUser.setName("系统管理员");
innerUser.setUsername("admin");
innerUser.setPassword(new EncryptionMD5().getModifyMD5("admin"));
innerUser.setPosition("信息工程师");
innerUser.setTel("13632657240");
innerUser.setUseable("1");
impl.addNewInnerUser(innerUser);
}
}
使用spring.test+junit4测试的时候
在service保存的时候泛型DAO报错:错误指向--->getHibernateTemplate().save(entity);
提示空指针
#3
好像没注入对,不知道配置有没有问题,帮忙看看!
#4
看看是否dO主键属性是否设置 建议设置断点排查
#5
跟主键没有关系,spring.test+junit测试的时候,HibernateTemplate注入不了?
#6
<bean id="GenericHibernateDao" class="com.postek.dsmis.common.util.hibernate.GenericHibernateDao">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
hibernateTemplate注入啊
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
hibernateTemplate注入啊
#7
package com.unite.dao.impl;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import com.unite.dao.UserDao;
import com.unite.entity.PageModel;
import com.unite.entity.User;
import com.unite.util.UtilTool;
/**
* 测试类
* 注意事项:测试前把applicationContext.xml文件的dwr配置给注释掉,否则报错
* */
@ContextConfiguration("/applicationContext.xml")
public class TestDaoImpl extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private UserDao userDao;
@Autowired
private UtilTool tool;
@Test
@Rollback(false)
public void testAdd() {
User user = new User();
user.setUserName("王五");
user.setPassword(tool.md5("wangwu"));
user = userDao.add(user);
assertTrue(null != user.getId());
System.out.println("注册成功");
}
@Test
public void testLogin() {
Boolean result = userDao.login("admin", tool.md5("111qqq"));
assertTrue(result);
System.out.println("登录成功");
}
}
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import com.unite.dao.UserDao;
import com.unite.entity.PageModel;
import com.unite.entity.User;
import com.unite.util.UtilTool;
/**
* 测试类
* 注意事项:测试前把applicationContext.xml文件的dwr配置给注释掉,否则报错
* */
@ContextConfiguration("/applicationContext.xml")
public class TestDaoImpl extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private UserDao userDao;
@Autowired
private UtilTool tool;
@Test
@Rollback(false)
public void testAdd() {
User user = new User();
user.setUserName("王五");
user.setPassword(tool.md5("wangwu"));
user = userDao.add(user);
assertTrue(null != user.getId());
System.out.println("注册成功");
}
@Test
public void testLogin() {
Boolean result = userDao.login("admin", tool.md5("111qqq"));
assertTrue(result);
System.out.println("登录成功");
}
}
#8
这个是通用DAO
public class GenericHibernateDao<T extends Serializable, PK extends Serializable> extends HibernateDaoSupport
implements GenericDao<T, PK> {
@Resource(name="hibernateTemplate")
public void setSuperHibernateTemplate(HibernateTemplate hibernateTemplate) {
//System.out.println("--------:"+hibernateTemplate);
super.setHibernateTemplate(hibernateTemplate);
System.out.println("-----1111111111---:"+getHibernateTemplate());
System.out.println("-----2222222222---:"+getSession());
}
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
System.out.println("getHibernateTemplate()--------"+getHibernateTemplate());
System.out.println("super.getHibernateTemplate()--------"+getHibernateTemplate());
super.getHibernateTemplate().save(entity);
}
输出结果:
-----1111111111---:org.springframework.orm.hibernate3.HibernateTemplate@58cca9
-----2222222222---:SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
com.postek.dsmis.model.InnerUser@e5ace9
getHibernateTemplate()--------null
super.getHibernateTemplate()--------null
"hibernateTemplate"是注入进去了,但是,泛型GenericHibernateDao的save方法中的getHibernateTemplate()都为空,何故啊?
public class GenericHibernateDao<T extends Serializable, PK extends Serializable> extends HibernateDaoSupport
implements GenericDao<T, PK> {
@Resource(name="hibernateTemplate")
public void setSuperHibernateTemplate(HibernateTemplate hibernateTemplate) {
//System.out.println("--------:"+hibernateTemplate);
super.setHibernateTemplate(hibernateTemplate);
System.out.println("-----1111111111---:"+getHibernateTemplate());
System.out.println("-----2222222222---:"+getSession());
}
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
System.out.println("getHibernateTemplate()--------"+getHibernateTemplate());
System.out.println("super.getHibernateTemplate()--------"+getHibernateTemplate());
super.getHibernateTemplate().save(entity);
}
输出结果:
-----1111111111---:org.springframework.orm.hibernate3.HibernateTemplate@58cca9
-----2222222222---:SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
com.postek.dsmis.model.InnerUser@e5ace9
getHibernateTemplate()--------null
super.getHibernateTemplate()--------null
"hibernateTemplate"是注入进去了,但是,泛型GenericHibernateDao的save方法中的getHibernateTemplate()都为空,何故啊?
#9
把你的sessionFectory Bean直接注入给你的*DaoImpl类
#1
注入对了没有啊 ?
#2
通用泛型DAO,GenericHibernateDao.save方法为:
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
getHibernateTemplate().save(entity);
}
----------------------测试代码-----------------------------
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class TestSpring extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void addNewUser() throws NoSuchAlgorithmException {
InnerUserServiceImpl impl = new InnerUserServiceImpl();
InnerUser innerUser = new InnerUser();
innerUser.setDepartmentId("1");
innerUser.setDepartmentName("信息");
innerUser.setLastloginAdrees(null);
innerUser.setLastLoginIp(null);
innerUser.setLastloginTime(null);
innerUser.setName("系统管理员");
innerUser.setUsername("admin");
innerUser.setPassword(new EncryptionMD5().getModifyMD5("admin"));
innerUser.setPosition("信息工程师");
innerUser.setTel("13632657240");
innerUser.setUseable("1");
impl.addNewInnerUser(innerUser);
}
}
使用spring.test+junit4测试的时候
在service保存的时候泛型DAO报错:错误指向--->getHibernateTemplate().save(entity);
提示空指针
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
getHibernateTemplate().save(entity);
}
----------------------测试代码-----------------------------
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class TestSpring extends AbstractTransactionalJUnit4SpringContextTests {
@Test
public void addNewUser() throws NoSuchAlgorithmException {
InnerUserServiceImpl impl = new InnerUserServiceImpl();
InnerUser innerUser = new InnerUser();
innerUser.setDepartmentId("1");
innerUser.setDepartmentName("信息");
innerUser.setLastloginAdrees(null);
innerUser.setLastLoginIp(null);
innerUser.setLastloginTime(null);
innerUser.setName("系统管理员");
innerUser.setUsername("admin");
innerUser.setPassword(new EncryptionMD5().getModifyMD5("admin"));
innerUser.setPosition("信息工程师");
innerUser.setTel("13632657240");
innerUser.setUseable("1");
impl.addNewInnerUser(innerUser);
}
}
使用spring.test+junit4测试的时候
在service保存的时候泛型DAO报错:错误指向--->getHibernateTemplate().save(entity);
提示空指针
#3
好像没注入对,不知道配置有没有问题,帮忙看看!
#4
看看是否dO主键属性是否设置 建议设置断点排查
#5
跟主键没有关系,spring.test+junit测试的时候,HibernateTemplate注入不了?
#6
<bean id="GenericHibernateDao" class="com.postek.dsmis.common.util.hibernate.GenericHibernateDao">
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
hibernateTemplate注入啊
<property name="hibernateTemplate" ref="hibernateTemplate"></property>
</bean>
hibernateTemplate注入啊
#7
package com.unite.dao.impl;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import com.unite.dao.UserDao;
import com.unite.entity.PageModel;
import com.unite.entity.User;
import com.unite.util.UtilTool;
/**
* 测试类
* 注意事项:测试前把applicationContext.xml文件的dwr配置给注释掉,否则报错
* */
@ContextConfiguration("/applicationContext.xml")
public class TestDaoImpl extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private UserDao userDao;
@Autowired
private UtilTool tool;
@Test
@Rollback(false)
public void testAdd() {
User user = new User();
user.setUserName("王五");
user.setPassword(tool.md5("wangwu"));
user = userDao.add(user);
assertTrue(null != user.getId());
System.out.println("注册成功");
}
@Test
public void testLogin() {
Boolean result = userDao.login("admin", tool.md5("111qqq"));
assertTrue(result);
System.out.println("登录成功");
}
}
import org.junit.Test;
import static org.junit.Assert.assertTrue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import com.unite.dao.UserDao;
import com.unite.entity.PageModel;
import com.unite.entity.User;
import com.unite.util.UtilTool;
/**
* 测试类
* 注意事项:测试前把applicationContext.xml文件的dwr配置给注释掉,否则报错
* */
@ContextConfiguration("/applicationContext.xml")
public class TestDaoImpl extends AbstractTransactionalJUnit4SpringContextTests {
@Autowired
private UserDao userDao;
@Autowired
private UtilTool tool;
@Test
@Rollback(false)
public void testAdd() {
User user = new User();
user.setUserName("王五");
user.setPassword(tool.md5("wangwu"));
user = userDao.add(user);
assertTrue(null != user.getId());
System.out.println("注册成功");
}
@Test
public void testLogin() {
Boolean result = userDao.login("admin", tool.md5("111qqq"));
assertTrue(result);
System.out.println("登录成功");
}
}
#8
这个是通用DAO
public class GenericHibernateDao<T extends Serializable, PK extends Serializable> extends HibernateDaoSupport
implements GenericDao<T, PK> {
@Resource(name="hibernateTemplate")
public void setSuperHibernateTemplate(HibernateTemplate hibernateTemplate) {
//System.out.println("--------:"+hibernateTemplate);
super.setHibernateTemplate(hibernateTemplate);
System.out.println("-----1111111111---:"+getHibernateTemplate());
System.out.println("-----2222222222---:"+getSession());
}
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
System.out.println("getHibernateTemplate()--------"+getHibernateTemplate());
System.out.println("super.getHibernateTemplate()--------"+getHibernateTemplate());
super.getHibernateTemplate().save(entity);
}
输出结果:
-----1111111111---:org.springframework.orm.hibernate3.HibernateTemplate@58cca9
-----2222222222---:SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
com.postek.dsmis.model.InnerUser@e5ace9
getHibernateTemplate()--------null
super.getHibernateTemplate()--------null
"hibernateTemplate"是注入进去了,但是,泛型GenericHibernateDao的save方法中的getHibernateTemplate()都为空,何故啊?
public class GenericHibernateDao<T extends Serializable, PK extends Serializable> extends HibernateDaoSupport
implements GenericDao<T, PK> {
@Resource(name="hibernateTemplate")
public void setSuperHibernateTemplate(HibernateTemplate hibernateTemplate) {
//System.out.println("--------:"+hibernateTemplate);
super.setHibernateTemplate(hibernateTemplate);
System.out.println("-----1111111111---:"+getHibernateTemplate());
System.out.println("-----2222222222---:"+getSession());
}
// 存储实体到数据库
public void save(T entity) {
System.out.println(entity);
System.out.println("getHibernateTemplate()--------"+getHibernateTemplate());
System.out.println("super.getHibernateTemplate()--------"+getHibernateTemplate());
super.getHibernateTemplate().save(entity);
}
输出结果:
-----1111111111---:org.springframework.orm.hibernate3.HibernateTemplate@58cca9
-----2222222222---:SessionImpl(PersistenceContext[entityKeys=[],collectionKeys=[]];ActionQueue[insertions=[] updates=[] deletions=[] collectionCreations=[] collectionRemovals=[] collectionUpdates=[]])
com.postek.dsmis.model.InnerUser@e5ace9
getHibernateTemplate()--------null
super.getHibernateTemplate()--------null
"hibernateTemplate"是注入进去了,但是,泛型GenericHibernateDao的save方法中的getHibernateTemplate()都为空,何故啊?
#9
把你的sessionFectory Bean直接注入给你的*DaoImpl类