加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – BeanNotOfRequiredTypeException但实际上是$Proxy类型

发布时间:2020-12-14 05:56:42 所属栏目:Java 来源:网络整理
导读:我需要帮助解决 Spring和代理问题. 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] or
我需要帮助解决 Spring和代理问题.

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: 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项目 – >

春天上下文

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

解决方法

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读