BeanNotOfRequiredTypeException但实际上是$ Proxy类型 [英] BeanNotOfRequiredTypeException but was actually of type $Proxy

查看:951
本文介绍了BeanNotOfRequiredTypeException但实际上是$ Proxy类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need help with a problem with Spring and proxy.


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

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'fooAPIService' must be of type [com.foo.clientapi.service.FooAPIService], but was actually of type [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]类型的

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'activityController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'fooAPIService' must be of type [com.foo.clientapi.service.FooAPIService], but was actually of type [com.sun.proxy.$Proxy110]

Webapp项目 - >

Webapp project ->

Spring-context

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

ActivityController.class

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

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

@Resource
private FooAPIService fooAPIService;

...
}

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

Another project (micro-service) ->

FooAPIService.class

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
春天3.2.2

Version : aspectjweaver : 1.6.10 aspectjrt : 1.6.11 cglib : 2.2 Spring 3.2.2

推荐答案

问题是我有两个豆子(jaxrs:客户)具有相同的ID(名称)。

The problem was that I had two beans(jaxrs:client) with the same id (name).

这篇关于BeanNotOfRequiredTypeException但实际上是$ Proxy类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆