你在哪里定义spring bean配置文件

Ank*_*kur 4 java configuration spring exception

我正在分离我的spring bean配置文件,如下所示:

myapp-service.xml myapp-servlet.xml

但是我得到了错误;

在ServletContext资源[/WEB-INF/myapp-servlet.xml]中定义名称为'beanName'的bean时出错:在设置bean属性'beanService'时无法解析对bean'beanService'的引用; 嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有定义名为'beanService'的bean

所有我需要做的(我认为)是弄清楚如何告诉Spring读取定义了beanService路径的myapp-service.xml文件.

完成了哪个文件/位置?

谢谢

cle*_*tus 6

它在您的web.xml中定义:

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)

或者在myapp-servlet.xml中你可以放:

<import resource="myapp-service.xml"/>
Run Code Online (Sandbox Code Playgroud)