[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.classpath에 스프링 콩이 있니?
classpath에 스프링 콩이 있니?
이 오류는 일반적으로 spring.schemas (spring-beans.jar에 있음)가 해당 네임 스페이스의 의미를 설명하는 것을 찾을 수 없음을 의미합니다.
다른 옵션은 Maven Shade 플러그인이 spring.schemas를 손상 시켰지만 Maven에 대해 언급하지 않았기 때문에 그럴 가능성은 희박합니다.
-
==============================
2.아마이 게시물은 당신을 도울 수 있습니다 :
아마이 게시물은 당신을 도울 수 있습니다 :
인터넷 오프라인 모드에서 'beans'요소 선언을 찾을 수 없습니다.
스키마 구성에 문제가있는 것처럼 보입니다.
-
==============================
3.maven shade plugin은 jar 파일의 spring.schemas 파일을 대체하는 것으로 보이므로 각 Jar 파일의 모든 개별 spring.schema 내용을 사용하여 자체 파일 중 하나를 만드는 것이 문제를 해결해야합니다.
maven shade plugin은 jar 파일의 spring.schemas 파일을 대체하는 것으로 보이므로 각 Jar 파일의 모든 개별 spring.schema 내용을 사용하여 자체 파일 중 하나를 만드는 것이 문제를 해결해야합니다.
-
==============================
4.STS에서이 문제가 발생했을 때 나는 방금 프로젝트를 정리했고 효과가있었습니다.
STS에서이 문제가 발생했을 때 나는 방금 프로젝트를 정리했고 효과가있었습니다.
-
==============================
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 릴리스
클래스 경로 버전을 확인하고 동일하게 유지하십시오. 소울
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
'SPRING' 카테고리의 다른 글
[SPRING] Spring 데이터 나머지 페이지 가능 자식 콜렉션 (0) | 2019.02.17 |
---|---|
[SPRING] 빈으로 새 대기열, 바인딩 및 교환을 동적으로 추가 (0) | 2019.02.17 |
[SPRING] Spring 부트 jdbc 데이터 소스 자동 구성이 독립형 Tomcat에서 실패합니다. (0) | 2019.02.17 |
[SPRING] Java 9로 전환 할 때 Spring 부트를 사용하는 javax.xml.bind.JAXBException의 ClassNotFoundException (1) | 2019.02.17 |
[SPRING] Quartz JDBCJobStore에서 작업을 어떻게 비활성화 할 수 있습니까? (0) | 2019.02.17 |