본문 바로가기

웹 개발(OLD)/Spring Framework(OLD)

요소 콘텐츠는 올바른 형식의 문자 데이터 또는 마크업으로 구성되어야 합니다.

WARN : org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [C:\Users\woojin\Documents\workspace-sts-3.7.3.RELEASE\BoardPagingProject\src\main\webapp\WEB-INF\spring\root-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\Users\woojin\Documents\workspace-sts-3.7.3.RELEASE\BoardPagingProject\target\classes\mappers\boardMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 43; columnNumber: 5; 요소 콘텐츠는 올바른 형식의 문자 데이터 또는 마크업으로 구성되어야 합니다.



MyBatis 쿼리문을 xml파일에 mapper태그안에 작성해놓고 DAO 테스트 중에 위와 같은 에러가 났다.

이미 DB 연결 테스트는 했기 때문에 DB에 문제가 있는건 아니다. 그 문제는..

MyBatis에서는 부등호( <, > ) 사용시 <![CDATA[  여기에    ]]> 사용해 주어야 한다.

xml 태그의 부등호가 같기 때문에 파싱시 에러가 발생하는 것이다.

아무튼 CDATA 섹션안에 쿼리문을 넣어주면 에러가 나지 않는다.


ex>

select

*

from

tbl_board

where 

bno <![CDATA[ > ]]> 0

oreder by

order by bno desc, regdate desc



끝.