Mybatis Could not find value method on SQL annotation错误

在使用MyBatis注释方式开发DAO类时,遇到SQL语法错误导致的BuilderException。错误源于SQL语句中使用了未经转义的特殊字符<>,通过将其替换为!=解决了问题。

参与一个项目的开发,我用mybatis 注释的方式写了一个dao类,里面用到了script,运行时发生错误

org.apache.ibatis.builder.BuilderException: Could not find value method on SQL annotation.  Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 285; 元素内容必须由格式正确的字符数据或标记组成。
	at com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getSqlSourceFromAnnotations(MybatisMapperAnnotationBuilder.java:495)
	at com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parseStatement(MybatisMapperAnnotationBuilder.java:311)
	at com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.parse(MybatisMapperAnnotationBuilder.java:155)
	at com.baomidou.mybatisplus.core.MybatisMapperRegistry.addMapper(MybatisMapperRegistry.java:86)

该错误是由于我写的sql语句使用了特殊符号,这种情况需要把特殊字符转义。我的错误是由于条件判断中使用了不等号<>引起,我将<>改成 != 解决该问题

上一个回答的代码启动报错Error creating bean with name 'advertController' defined in file [E:\IdeaProjects\taihaolian\target\classes\com\ruifan\taihaolian\biz\controller\AdvertController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'advertServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'advertMapper' defined in file [E:\IdeaProjects\taihaolian\target\classes\com\ruifan\taihaolian\biz\mapper\AdvertMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [tk/mybatis/mapper/autoconfigure/MapperAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\IdeaProjects\taihaolian\target\classes\mapper\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Could not find value method on SQL annotation. Cause: org.apache.ibatis.builder.BuilderException: Error creating SqlSource for SqlProvider. Method 'selectByRoleAndPage' not found in SqlProvider 'org.apache.ibatis.annotations.SelectProvider'.
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值