我正在构建一个通过 java config 而不是 xml 配置 spring 的新应用程序。此应用程序依赖于使用 xml 样式配置的模块。当我尝试启动我的应用程序时,我收到以下错误:
No qualifying bean of type [com.myModule.myServiceImp] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
这个 bean 应该在模块的 applicationContext.xml 中声明。处理这个问题的正确方法是什么?如果我在应用程序的 web.xml 中将应用程序上下文串在一起,我尝试简单地添加它:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:com/myModule/appbase-context.xml
com.myApp.AppConfig
</param-value>
</context-param>
但我仍然遇到同样的错误。这样做的正确方法是什么?