BeanNotOfRequiredTypeException异常,但实际类型为$Proxy。

7
我需要帮助解决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]

Web应用程序项目 ->
Spring-context
<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

(注:本文中“class”指Java类)
@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

1个回答

11

问题在于我有两个相同id(名称)的豆子(jaxrs:client)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接