情况说明:

金仓数据库ES V7​

在sqlserver中使用<>判断写法在mybatis里面报错的问题,把sql语句在金仓查询编辑器里面运行不会报错。启动项目时报相关类文件无法创建。

Xml文件sql语句:

<where>

        1=1 and IsOpen='1' and status='1'

        <if test="isParent != null and isParent == false "> 

         AND TableName <> 'HR_Source_UserBaseInfo'

        </if>

 </where>

错误信息:

 严重: Exception sending context initialized event to listener instance of class data.framework.support.GlobalContextListener

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseDataControll': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private data.hr.basedata.service.BaseDataService data.hr.basedata.controller.BaseDataControll.baseDataService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseDataService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.mybatis.spring.SqlSessionTemplate data.framework.support.AbstractService.template; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionTemplate' defined in ServletContext resource [/WEB-INF/classes/mybatis.xml]: Cannot resolve reference to bean 'sqlSessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource [/WEB-INF/classes/mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [C:\work\03_tomcat\eclipse-jee-photon-R-win32-x86_64-4.8\hpwjwoa-gch\apache-tomcat-7.0.69-oa-8080\webapps\hpwjwoa-gch\WEB-INF\classes\resource\mapper\oa\hr\system\sourceTableMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 22; columnNumber: 28; The content of elements must consist of well-formed character data or markup.

 

 

三、解决办法:

在mybatis中把<>判断改为!=。(红色字体是修改部分)

原xml语句:

<where>

        1=1 and IsOpen='1' and status='1'

        <if test="isParent != null and isParent == false "> 

         AND TableName <> 'HR_Source_UserBaseInfo'

        </if>

 </where>

修改为:

<where>

       1=1 and IsOpen='1' and status='1'

       <if test="isParent != null and isParent == false "> 

            AND TableName !='HR_Source_UserBaseInfo'

       </if>

 </where>

 

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐