嗨,我有这门课要做测试:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/service.xml"})
public class Test {
@Autowired private CommonService commonService;
在调试时,我在 CommonService 上获得了一个具有属性 h 的对象,它是一个 SdkDynamicAopProxy。
如何在我的属性 commonService 上获得一个 CommonServiceImp 对象?
公共服务
public interface CommonService {...}
公共服务小鬼
@Service("commonService")
@Transactional("transactionManager")
public class CommonServiceImp implements CommonService {
@Autowired private CommonDaoJdbcImp commonDao; ...}
服务.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:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-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/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.0.xsd">
<import resource="/bbb-dao.xml"/>
<context:component-scan base-package="aaa.bbb.service"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- <bean id="transactionManager" class="org.springframework.transaction.jta.WebSphereUowTransactionManager" /> -->
<tx:annotation-driven />
<task:annotation-driven />