Max*_*meF 7 java spring spring-aop cglib aspect
我需要帮助解决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/>
Run Code Online (Sandbox Code Playgroud)
ActivityController.class
import com.foo.clientapi.service.FooAPIService;
...
@Controller
@RequestMapping(value = "/toto")
public class ActivityController {
@Resource
private FooAPIService fooAPIService;
...
}
Run Code Online (Sandbox Code Playgroud)
另一个项目(微服务) - >
FooAPIService.class
@Path("/foos")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public interface FooAPIService {
...
}
Run Code Online (Sandbox Code Playgroud)
Jaxrs配置:
<jaxrs:client id="fooAPIService"
address="${toto}"
threadSafe="true"
serviceClass="com.foo.clientapi.service.FooAPIService"
inheritHeaders="true">
...
</jaxrs:client>
Run Code Online (Sandbox Code Playgroud)
版本:aspectjweaver:1.6.10 aspectjrt:1.6.11 cglib:2.2 Spring 3.2.2