BeanNotOfRequiredTypeException但实际上是$ Proxy类型

问题描述 投票:7回答:1

我需要帮助解决Spring和代理问题。

org.springframework.beans.factory.BeanNotOfRequiredTypeException:名为'fooAPIService'的bean必须是[com.foo.clientapi.service.FooAPIService]类型,但实际上是[com.sun.proxy。$ Proxy110]类型

org.springframework.beans.factory.BeanCreationException:创建名为'activityController'的bean时出错:资源依赖注入失败;嵌套异常是org.springframework.beans.factory.BeanNotOfRequiredTypeException:名为'fooAPIService'的bean必须是[com.foo.clientapi.service.FooAPIService]类型,但实际上是[com.sun.proxy。$ Proxy110]类型

Webapp项目 - >

春天上下文

<context:annotation-config/>
<context:component-scan base-package="com.foo.controller"/>
<aop:aspectj-autoproxy />
<aop:config proxy-target-class="true"/>
<mvc:annotation-driven/>

ActivityController.class

import com.foo.clientapi.service.FooAPIService;
...

@Controller
@RequestMapping(value = "/toto")
public class ActivityController {

@Resource
private FooAPIService fooAPIService;

...
}

另一个项目(微服务) - >

FooAPIService.class

@Path("/foos")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface FooAPIService {

...
}

Jaxrs配置:

<jaxrs:client id="fooAPIService"
              address="${toto}"
              threadSafe="true"
              serviceClass="com.foo.clientapi.service.FooAPIService"
              inheritHeaders="true">
    ...
</jaxrs:client>

版本:aspectjweaver:1.6.10 aspectjrt:1.6.11 cglib:2.2 Spring 3.2.2

java spring spring-aop cglib aspect
1个回答
11
投票

问题是我有两个具有相同id(名称)的bean(jaxrs:client)。

© www.soinside.com 2019 - 2024. All rights reserved.