【问题标题】:BeanNotOfRequiredTypeException but was actually of type $ProxyBeanNotOfRequiredTypeException 但实际上是 $Proxy 类型
【发布时间】:2014-12-09 09:33:45
【问题描述】:

我需要有关 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 方面jrt:1.6.11 cglib:2.2 春季 3.2.2

【问题讨论】:

    标签: java spring spring-aop cglib aspect


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2019-03-07
      • 2021-03-21
      • 2012-01-13
      • 2016-07-18
      • 1970-01-01
      • 2019-03-17
      • 2018-10-05
      • 2018-09-18
      • 2021-07-18
      相关资源
      最近更新 更多