有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java BeanOfRequiredTypeException,但实际上是$Proxy类型

我需要帮助解决Spring和proxy的问题

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

Spring上下文

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

活动控制器。阶级

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

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

@Resource
private FooAPIService fooAPIService;

...
}

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

食品服务。阶级

@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


共 (1) 个答案

  1. # 1 楼答案

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