org.xml.sax.SAXParseException: 元素类型 “select“ 必须后跟属性规范 “>“ 或 “/>

项目场景:

springBoot项目build编译成功,maven依赖都没问题,项目启动run服务的时候报异常:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoUserController': Unsatisfied dependency expressed through field 'demoUserService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoUserServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoUserMapper' defined in file [E:\workspace\financial-attendance\target\classes\com\luntek\financialattendance\mapper\DemoUserMapper.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 [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.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:\workspace\financial-attendance\target\classes\mapper\StProjectApproveMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 104; columnNumber: 28; 元素类型 "select" 必须后跟属性规范 ">" 或 "/>"。


问题描述和分析

问题已经很清楚了,创建mapper.xml文件实例失败,也指出了是`\mapper\StProjectApproveMapper.xml`这个xml文件的`lineNumber: 104; columnNumber: 28`104行28列有问题

org.xml.sax.SAXParseException: 元素类型 “select“ 必须后跟属性规范 “>“ 或 “/>_第1张图片


解决方案:

已经定位到写select语句的时候,设置`parameterType`参数类型的时候是少了个空格。补上即可。 

org.xml.sax.SAXParseException: 元素类型 “select“ 必须后跟属性规范 “>“ 或 “/>_第2张图片

总结:

springBoot项目build编译是不会检查xml的语法,mapper.xml文件是项目运行时java虚拟机根据mybaits创建文件实例的时候检查报错,遇到问题不用慌,错误日志看起来。

你可能感兴趣的:(JAVA开发,xml,javascript,java,spring,boot,mybatis)