Spring自动从包中加载上下文文件(不添加监听器)。 我无法在 web.xml 中添加以下监听器。如果我添加它们,它会显示错误。spring 是否有任何选项,它会自动扫描包并加载 XML。
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
<param-name>contextConfiglocation</param-name>
<param-value>
classpath:com/preprogrammer/recruiterbox/config/dao-context.xml
</param-value>
</context-param>
最佳答案
<import resource="classpath:applicationContext.xml" />
您可以将其导入到 servert.xml 文件中。
如果你的 XML 在类路径中可用,spring 会处理它。不需要监听器。
关于java - Spring自动从包中加载上下文文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43743714/