我有一个外部库,由maven的依赖项添加了
<dependency>
<grouId>...
此库中有一个服务类,其服务类型为带有@Resource批注的Map类型
@Service
public class ExternalServiceImpl implements ExternalService{
@Resource
private Map<String, String> externalMap;
..
}
此映射是在lib的XML中定义的
<util:map id="externalMap" map-class="java.util.HashMap">
<entry key="A" value = "B"/>
...
</util:map>
在我的应用程序中,我已经在XML中添加了打包的路径
<context:component-scan base-package="com.app.external.services"/>
我正在服务类中自动装配外部服务
@Component
public class MyResouce{
@Autowire
private ExternalService externalService;
..
}
在本地启动tomcat时,它在创建bean时崩溃
Caused by: org.springframework.beans.factory.NoSuchBeanDefinition: No qualifying bean of type [java.lang.String] found for dependency [map wiith value type java.lang.String]: expected at least 1 bean which qualifies as autowire candidate for this depeendency. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
有什么想法吗?我已经玩了一段时间了,不知道如何解决