我需要帮助解决Spring和代理问题。
Spring-context
Web应用程序项目 ->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]
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