简体   繁体   English

在SpringContext.xml中找不到元素'beans'的声明

[英]Cannot find the declaration of element 'beans' inside SpringContext.xml

I am invoking a spring bean from a java class, and is calling that java class from a scala program. 我从Java类中调用Spring bean,并从Scala程序中调用该Java类。 I have packeged my program inside a jar using maven and is exploding the spring dependency inside it. 我已经使用maven将程序打包在一个jar中,并且正在分解其中的spring依赖项。 But when calling the bean it is throwing the falling exception- 但是当调用bean时,它抛出了下降的异常-

> User class threw exception: Job aborted due to stage failure: Task 0
> in stage 5.0 failed 4 times, most recent failure: Lost task 0.3 in
> stage 5.0 (TID 6, hostname03):
> org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
> Line 6 in XML document from URL
> [jar:file:/hadoop/yarn/local/usercache/root/filecache/101/SomeJar-1.0-SNAPSHOT-job.jar!/SpringContext.xml]
> is invalid; nested exception is org.xml.sax.SAXParseException;
> lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the
> declaration of element 'beans'. at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
> at
> org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)

My SpringContext.xml looks like- 我的SpringContext.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-3.0.xsd">

    <import resource="classpath:RuleSpringContext.xml" />
<bean id="serviceImpl" class="com.org.name.services.dao.ServiceImpl" /> 

    <bean id="contextInitializer" class="com.org.name.services.config.AppContextInitializer" />

</beans>

Any help will be much appreciated. 任何帮助都感激不尽。 Also when I am running the program from eclipse bean is getting invoked its just that when I am running my jar the issue is coming. 另外,当我从eclipse bean运行程序时,它正被调用,恰恰是我在运行jar时出现了问题。 I am using spark-submit to run the jar. 我正在使用spark-submit来运行jar。

It seems xml xsi:schemaLocation declaration wrong. 似乎xml xsi:schemaLocation声明错误。

xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-[version].xsd

Replace the [version] with appropriate spring version you are using. 将[version]替换为您使用的适当的spring版本。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到元素&#39;beans&#39;的声明。 - Cannot find the declaration of element 'beans'. 找不到元素“beans”的声明 - Cannot find the declaration of element 'beans' org.xml.sax.SAXParseException; 找不到元素&#39;beans:beans的声明 - org.xml.sax.SAXParseException; Cannot find the declaration of element 'beans:beans spring gwt找不到元素&#39;beans&#39;的声明 - spring gwt Cannot find the declaration of element 'beans' 找不到元素&#39;beans&#39;的声明。 在春天 - Cannot find the declaration of element 'beans'. in spring Spring org.xml.sax.SAXParseException找不到元素&#39;beans&#39;的声明 - Spring org.xml.sax.SAXParseException Cannot find the declaration of element 'beans' org.xml.sax.SAXParseException; lineNumber:6; columnNumber:122; cvc-elt.1:找不到元素&#39;beans&#39;的声明 - org.xml.sax.SAXParseException; lineNumber: 6; columnNumber: 122; cvc-elt.1: Cannot find the declaration of element 'beans' root-context.xml] 无效; 嵌套异常是 org.xml.sax.SAXParseException; cvc-elt.1: 找不到元素 'beans' 的声明 - root-context.xml] is invalid; nested exception is org.xml.sax.SAXParseException; cvc-elt.1: Cannot find the declaration of element 'beans' 上下文初始化失败(找不到元素&#39;beans&#39;的声明)-Spring MVC - Context initialization failed (Cannot find the declaration of element 'beans') - Spring MVC 运行jar时找不到元素&#39;beans&#39;的声明错误 - Cannot find the declaration of element 'beans' error occur when run jar
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM