mapper 提示The content of elements must consist of well-formed character data or markup

本文解决了在mapper文件中添加SQL语句时遇到的符号解析问题,详细介绍了如何正确使用CDATA来包裹动态SQL语句中的特殊字符,避免XML解析错误。

今天在mapper 文件夹中添加相关的SQL语句,结果提示:“The content of elements must consist of well-formed character data or markup”

解决办法:

配置的动态SQL语句里面带 “<” “>” 等符号的用

<![CDATA[

]]>

括起来

package com.lenovo.ofp.order.throwengine.dao; import com.lenovo.ofp.order.domain.throwengine.domain.PaymentMessageVo; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; import java.util.List; /** * @Author: zengdy1 * @Date: 2025-09-16 17:50 */ public interface PaymentJobMapper { @Select({ "<script>", "SELECT * FROM ordercommon.t_payment_message", "WHERE process_status = 0", "AND message_type IN", "<foreach collection='messageTypes' item='messageType' open='(' separator=',' close=')'>", "#{messageType}", "</foreach>", "AND create_time > (CURRENT_DATE - INTERVAL '${limit} day')", "</script>" }) List<PaymentMessageVo> getPaymentMessageByType(@Param("messageType") List<Integer> messageType, @Param("limit") Integer limit); @Update({ "<script>", "UPDATE ordercommon.t_payment_message", "SET process_status = 1", "WHERE id IN", "<foreach collection='paymentMessageList' item='item' index='index' open='(' separator=',' close=')'>", "#{item.id}", "</foreach>", "</script>" }) void batchUpdateProcessStatus(@Param("paymentMessageList") List<PaymentMessageVo> authNotifyList);//实现这个批量更新sql @Delete({ "<script>", "DELETE FROM ordercommon.t_payment_message where process_status = 1 AND create_time < (CURRENT_DATE - INTERVAL '${limit} day') ", "</script>" }) Integer batchDelete( @Param("limit") Integer limit); List<PaymentMessageVo> getPaymentMessageByType(int limit); } 结合这个类 分析这个错误org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'paymentMessageJob': Unsatisfied dependency expressed through field 'orderPaymentMapper': Error creating bean with name 'throwPaymentJobMapper' defined in URL [jar:file:/app/lib/order-async-throw-1.0.3-SNAPSHOT.jar!/com/lenovo/ofp/order/throwengine/dao/PaymentJobMapper.class]: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 95; The content of elements must consist of well-formed character data or markup. at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredA
最新发布
09-18
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值