使用相对路径导入Spring bean定义文件

rightCoder

我正在用JAVA为我的项目编写弹簧配置。我是spring的新手,无法解决与spring相关的错误。我具有以下文件结构:

ProjectName
--> src
    --> META-INF
        --> jobs
            -->edx
               -->request-details.xml
            -->clients.xml
            -->daos.xml
            -->environment.xml
        --> request-details-edx-upload.xml

在META-INF / request-details-edx-upload.xml中,我导入以下内容:

<import resource="jobs/environment.xml" />
<import resource="classpath:META-INF/jobs/edx/request-details.xml" />
<import resource="jobs/clients.xml" />
<import resource="jobs/daos.xml" />

但我收到以下错误:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:META-INF/jobs/edx/request-details.xml]
Offending resource: class path resource [META-INF/request-details-edx-upload.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException:  Configuration problem: Cannot locate BeanDefinitionDecorator for attribute [dataSetName]
Offending resource: class path resource [META-INF/jobs/edx/request-details.xml]

request-details.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:util="http://www.springframework.org/schema/util"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
    ">
 <!-- RequestDetails EDX data upload dao -->
 <bean id="requestDetailsDataUploadDao" class="com.amazon.edx.dao.DataUploadDaoEdxClientImpl"
 context:providerName="scot"
 context:subjectName="${edxRequestDetailsSubject}"
 context:dataSetName="by-01-day"
 context:keyName="${regionValue}"
 context:edxClient-ref="edxClient"
 />
 <util:list id="requestDetailsColumnMetaData" value-type="com.amazon.edx.transformer.ColumnMetaData">
        <ref bean="Column"/>
        <ref bean="Column1"/>                   
 </util:list>
<bean id="Column" class="com.amazon.edx.transformer.ColumnMetaData"
    context:attributeName="Id"
    context:dataType="VARCHAR2"
    context:columnDisplayName="IMS"
/>    
<bean id="Column1" class="com.amazon.edx.transformer.ColumnMetaData"
    context:attributeName="id1"
    context:dataType="VARCHAR2"
    context:columnDisplayName="IMS"
/>
<util:constant id="tabDelimiter"
        static-field="com.amazon.edx.transformer.Delimiters.TAB_DELIMITER"    />


 <!-- RequestDetails data backup --> 
<bean id="requestDetailsDataTransformer" class="com.amazon.edx.transformer.DataTransformerImpl"
context:dataFlattener-ref="requestDetailsDataFlattener"
context:columnMetadata-ref="requestDetailsColumnMetaData"
context:delimiter="{tabDelimiter}"
/>
 </beans> 

导入相对路径是否有明显的错误?

谢谢。

肯·贝科夫(Ken Bekov)

似乎是错误的架构定义。尝试xmlns:context="http://www.springframework.org/schema/context"<beans>标记中删除namspace 而是添加xmlns:p="http://www.springframework.org/schema/p"名称空间。另外,您应将所有context:后缀替换p:后缀。使用带有p-namespace的快捷方式的正确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:util="http://www.springframework.org/schema/util"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/util
        http://www.springframework.org/schema/util/spring-util-3.0.xsd">

   <!-- RequestDetails EDX data upload dao -->
   <bean id="requestDetailsDataUploadDao" class="com.amazon.edx.dao.DataUploadDaoEdxClientImpl"
      p:providerName="scot"
      p:subjectName="${edxRequestDetailsSubject}"
      p:dataSetName="by-01-day"
      p:keyName="${regionValue}"
      p:edxClient-ref="edxClient"
   />

   ....

</beans>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章