복붙노트

[SPRING] 스프링으로 에러 메시지를받는 중 "cvc-elt.1 : 'beans'요소의 선언을 찾을 수 없습니다."

SPRING

스프링으로 에러 메시지를받는 중 "cvc-elt.1 : 'beans'요소의 선언을 찾을 수 없습니다."

간단한 스프링 응용 프로그램을 설정하려고하는데 아래 예외가 발생합니다. 이것은 일식 인디고에서 독립 실행 형으로 실행되고 있습니다.

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Line 2 in XML document from class path resource [context.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)

여기 내 코드의 초기 부분은 다음과 같습니다.

public static void main(String[] args) {

        try {

            BeanFactory beanfactory = new ClassPathXmlApplicationContext(
                    "context.xml");


            FirstBean bean = (FirstBean) beanfactory.getBean("show");

다음은 내 context.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">
<bean id="anotherBean" class="AnotherBean" />
<bean id="show" class="FirstBean">
<constructor-arg ref="anotherBean" />
</bean>
<bean id="populateFD" class="PopulateFactData">
<constructor-arg value="localhost" />
<constructor-arg value="3309" />
</bean>
</beans>

해결법

  1. ==============================

    1.classpath에 스프링 콩이 있니?

    classpath에 스프링 콩이 있니?

    이 오류는 일반적으로 spring.schemas (spring-beans.jar에 있음)가 해당 네임 스페이스의 의미를 설명하는 것을 찾을 수 없음을 의미합니다.

    다른 옵션은 Maven Shade 플러그인이 spring.schemas를 손상 시켰지만 Maven에 대해 언급하지 않았기 때문에 그럴 가능성은 희박합니다.

  2. ==============================

    2.아마이 게시물은 당신을 도울 수 있습니다 :

    아마이 게시물은 당신을 도울 수 있습니다 :

    인터넷 오프라인 모드에서 'beans'요소 선언을 찾을 수 없습니다.

    스키마 구성에 문제가있는 것처럼 보입니다.

  3. ==============================

    3.maven shade plugin은 jar 파일의 spring.schemas 파일을 대체하는 것으로 보이므로 각 Jar 파일의 모든 개별 spring.schema 내용을 사용하여 자체 파일 중 하나를 만드는 것이 문제를 해결해야합니다.

    maven shade plugin은 jar 파일의 spring.schemas 파일을 대체하는 것으로 보이므로 각 Jar 파일의 모든 개별 spring.schema 내용을 사용하여 자체 파일 중 하나를 만드는 것이 문제를 해결해야합니다.

  4. ==============================

    4.STS에서이 문제가 발생했을 때 나는 방금 프로젝트를 정리했고 효과가있었습니다.

    STS에서이 문제가 발생했을 때 나는 방금 프로젝트를 정리했고 효과가있었습니다.

  5. ==============================

    5.Spring Bean 버전과 xsd 정의의 불일치 가능성이있을 수 있습니다.

    Spring Bean 버전과 xsd 정의의 불일치 가능성이있을 수 있습니다.

    예를 들어 beans xsi : schemaLocation = "http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd

    스프링 버전은 3.0.5 릴리스

    클래스 경로 버전을 확인하고 동일하게 유지하십시오. 소울

  6. from https://stackoverflow.com/questions/10182857/getting-error-message-with-spring-cvc-elt-1-cannot-find-the-declaration-of-ele by cc-by-sa and MIT license