gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:13:31 24 4
gpt4 key购买 nike

我需要有关 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]

Web 应用项目 ->

Spring 上下文

<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.10aspectjrt:1.6.11cglib:2.2 Spring 3.2.2

最佳答案

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

关于java - BeanNotOfRequiredTypeException 但实际上是 $Proxy 类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26363376/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com