0

我想使用 Spring Data Populator,但我得到了SAXParseException

Exception in thread "main"
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: 

Configuration problem: Failed to import bean definitions from URL location
[classpath*:spring-context/dbContext.xml]

Offending resource: class path resource [spring-context/applicationContext.xml];

nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: 
Line 64 in XML document from URL [file:/home/pi/Workspace/AGServer/bin/spring-context/dbContext.xml] is invalid; 

nested exception is org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: 
Attribute 'location' is not allowed to appear in element 'repository:jackson-populator'.

我的主要服务器类是:

public final class ServerMain {

    private static final String APP_CONTEXT_XML = "spring-context/applicationContext.xml";

    public static void main(final String[] args) {
        final ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(APP_CONTEXT_XML);
        context.registerShutdownHook();
    }
}

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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <import resource="classpath*:spring-context/serverContext.xml" />
    <import resource="classpath*:spring-context/dbContext.xml" />
    <import resource="classpath*:spring-context/jettyContext.xml" />
</beans>

最后,我调用 Populator 的 dbContext.xml 的开头

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:repository="http://www.springframework.org/schema/data/repository"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
        http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository.xsd">

    <!-- AUTH DS / PU / TX / SERVICE -->
    <!-- the repositories configuration, ommited for clarity -->

    <repository:jackson-populator location="classpath:auth.json" />

这可能是由于与 spring-beans-3.0.xsd 的冲突造成的吗?我在所有(虽然不是太多,例如这里:http ://docs.spring.io/spring-data/commons/docs/1.5.1.RELEASE/reference/htmlsingle/???#d0e893 )文件中看到了那个春天-beans.xsd,不使用任何发布 ID。我试图改变它,但这并没有帮助。

4

0 回答 0