0

我有从类路径导入资源的 applicationcontext.xml 文件

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">
  
  <context:component-scan base-package="com.test"/>
  <context:annotation-config />
  <import resource="classpath:appBatchConfig.xml"/>

</beans>

我在 c:\config 文件夹中有所有配置文件,其中也包含 appBatchConfig.xml 文件。我已将 Wildfly 服务器配置为包含 c:\config 文件夹作为引导条目

在此处输入图像描述

但是加载 XML bean 定义,无法从类路径资源加载“appBatchConfig.xml”,以下是异常:

ERROR [org.springframework.beans.web.context.ContextLoader] (ServerService Thread Pool -- 111 ) Context initiallization failed: org.springframework.beans.parsing.BeanDefinitionParsingException: 
Configuration problem: Failed to import bean definition from URL location [classpath:appBatchConfig.xml]
Offending resource: ServletContext resource [/WEB-INF/resources/applicationcontext.xml]; 
nexted exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [appBatchConfig.xml]; 
nested exception is java.io.FileNotFoundException: class path resource [appBatchConfig.xml] cannot be opened because it does not exist

也尝试添加为用户条目,但没有运气,为什么文件夹中的属性和 xmls 不包含在类路径中?或者文件夹包含在类路径中但spring无法识别它?

4

0 回答 0