小编Pre*_*ton的帖子

为什么我的服务会自动连线到Proxy?

嗨,我有这个课要测试:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"/service.xml"})
public class Test {

    @Autowired private CommonService commonService;
Run Code Online (Sandbox Code Playgroud)

调试时,我在CommonService上获得一个对象,该对象的属性为SdkDynamicAopProxy。

如何在我的属性commonService上获得一个CommonServiceImp对象?

commonService

public interface CommonService {...}
Run Code Online (Sandbox Code Playgroud)

CommonServiceImp

@Service("commonService")
@Transactional("transactionManager")
public class CommonServiceImp implements CommonService {
    @Autowired private CommonDaoJdbcImp commonDao; ...}
Run Code Online (Sandbox Code Playgroud)

service.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 />
Run Code Online (Sandbox Code Playgroud)

java proxy aop spring autowired

1
推荐指数
1
解决办法
1431
查看次数

标签 统计

aop ×1

autowired ×1

java ×1

proxy ×1

spring ×1