개발관련/JAVA

[Spring Error] cvc-complex-type.2.3: Element 'beans' cannot have character [children]

90만식 2023. 4. 21. 16:57
728x90

에러 내용

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element 'beans' cannot have character [children], because the type's content type is element-only.
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source) ~[xercesImpl-2.9.1.jar:na]
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source) ~[xercesImpl-2.9.1.jar:na]
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[xercesImpl-2.9.1.jar:na]
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source) ~[xercesImpl-2.9.1.jar:na]

 

에러 원인

  • xml의 헤더 상단에 <?xml version="1.0" encoding="UTF-8" ?> 누락
  • xml상의 오타

 

에러 해결

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 36 in XML document from ServletContext resource [/WEB-INF/config/spring/context-datasource.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 36; columnNumber: 9; cvc-complex-type.2.3: Element 'beans' cannot have character [children], because the type's content type is element-only.

에러코드를 잘 살펴보니 context-datasource.xml 36번째 라인에 오타가 있어 수정 완료.

728x90