如何解决“可以找到元素'oxm:jaxb2-marshaller'的声明。”?

时间:2018-12-19 23:08:34

标签: java spring maven spring-oxm

前言:我正在开发基于Spring的Java应用程序。我仍在学习Spring,所以我可能错过了一些明显的解决方案。

每当我为此应用运行单元/集成测试时,其中一些自动测试就会失败,并显示以下错误:

java.lang.IllegalStateException: Failed to load ApplicationContext 
    at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
.
.
.
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 59; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'oxm:jaxb2-marshaller'. 
    at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)

这是失败的应用上下文文件:

<?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:oxm="http://www.springframework.org/schema/oxm"
       xsi:schemaLocation="
           http://www.springframework.org/schema/beans 
           http://www.springframework.org/schema/beans/spring-beans.xsd 
           http://www.springframework.org/schema/oxm 
           http://www.springframework.org/schema/oxm/spring-oxm.xsd">
  <oxm:jaxb2-marshaller id="myMarshaller">
    <oxm:class-to-be-bound name="com.me.types.MyClass" />
  </oxm:jaxb2-marshaller>
</beans>

这是我pom的相关部分:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-oxm</artifactId>
    <version>4.3.12.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.ws</groupId>
    <artifactId>spring-ws-core</artifactId>
    <version>2.4.0.RELEASE</version>
</dependency>
<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.9.1</version>
</dependency>

我不知道是什么阻止了应用上下文的旋转。我拉错了罐子吗?我是否错误地声明了我的命名空间?我的代理服务器有问题吗?

任何帮助将不胜感激。

0 个答案:

没有答案