Jeesite "choose" must match "(when*,otherwise?)".  xml报错

2018-11-27 13:57:35,963 WARN  [springframework.beans.factory.support.DefaultListableBeanFactory] - Bean creation exception on FactoryBean type check: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baikeCategoryDao' defined in file [D:\idea-workspace\ph_pox_enterprise_edition\src\main\webapp\WEB-INF\classes\com\thinkgem\jeesite\modules\lanstech\dao\BaikeCategoryDao.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\idea-workspace\ph_pox_enterprise_edition\src\main\webapp\WEB-INF\classes\spring\spring-context.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\idea-workspace\ph_pox_enterprise_edition\src\main\webapp\WEB-INF\classes\mappings\modules\lanstech\ShopOrderDao.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 70; columnNumber: 18; The content of element type "choose" must match "(when*,otherwise?)".
org.apache.ibatis.builder.BuilderException: Error creating document instance.  Cause: org.xml.sax.SAXParseException; lineNumber: 70; columnNumber: 18; The content of element type "choose" must match "(when*,otherwise?)".
	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:256)
	at org.apache.ibatis.parsing.XPathParser.<init>(XPathParser.java:125)
	at org.apache.ibatis.builder.xml.XMLMapperBuilder.<init>(XMLMapperBuilder.java:86)
	at org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:518)
	at org.mybatis.spring.SqlSessionFactoryBean.afterPropertiesSet(SqlSessionFactoryBean.java:374)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:351)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:108)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1475)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1220)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getTypeForFactoryBean(AbstractBeanFactory.java:1423)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:802)
	at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:542)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:436)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:412)
	at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:186)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1105)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:996)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:606)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1208)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:434)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
	at com.thinkgem.jeesite.modules.sys.listener.WebContextListener.initWebApplicationContext(WebContextListener.java:16)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
	at java.util.concurrent.FutureTask.run(FutureTask.java)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: org.xml.sax.SAXParseException; lineNumber: 70; columnNumber: 18; The content of element type "choose" must match "(when*,otherwise?)".
	at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
	at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.handleEndElement(Unknown Source)
	at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
	at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
	at org.apache.ibatis.parsing.XPathParser.createDocument(XPathParser.java:254)
	... 57 more

以上错误不定的重复,基本上每个xml文件都会有报错。

本错误的原因是在某一个xml 文件中的标签后存在 一个符号 。 

从报错中可以找到的线索就是"choose" must match "(when*,otherwise?)". 

在choose标签中没有规范使用。但是定位的时候是每个xml文件都报错。所有查找起来很麻烦。

我是用的笨方法,全局搜索的xml的choose。

 

 

这个的重点是:当所有的文件都报一个相同的错误的时候,要提取有效信息进行查找错误所在。

"choose" must match "(when*,otherwise?)". 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Mybatis中的choose、when、otherwise标签用于在SQL语句中编写条件分支逻辑。 choose标签类似于Java中的switch语句,可以根据条件选择执行不同的SQL语句。当choose标签的子标签when中的条件满足时,将执行该标签下的SQL语句。如果所有when条件都不满足,则执行otherwise标签下的SQL语句。 以下是一个示例: ``` <select id="selectUsers" resultMap="userResultMap"> SELECT * FROM users <where> <choose> <when test="orderBy == 'id'"> ORDER BY id </when> <when test="orderBy == 'name'"> ORDER BY name </when> <when test="orderBy == 'age'"> ORDER BY age </when> <otherwise> ORDER BY id </otherwise> </choose> </where> </select> ``` 在这个示例中,根据传入的orderBy参数来选择执行不同的ORDER BY子句。如果orderBy参数的值是'id'、'name'或'age',则分别执行相应的ORDER BY子句;否则,执行默认的ORDER BY id子句。 ### 回答2: MyBatis是一种流行的Java持久化框架,它提供了许多便捷的功能来简化数据库操作。其中选择语句(choose)是MyBatis中的一种强大功能,用于根据不同的条件执行不同的逻辑。 选择语句可用于替代标准的switch语句或if-else语句。它使用choose、when和otherwise关键字来构建多分支的逻辑判断。 当执行选择语句时,首先会依次判断每个when语句的条件,如果满足条件,则执行when语句内的逻辑。当某个when语句的条件满足时,它的逻辑块会被执行,同时选择语句的执行也会终止。如果所有的when语句都不满足条件,则执行otherwise语句内的逻辑。 当执行选择语句时,可以有多个when语句,每个when语句可以有一个或多个条件。条件可以是简单的比较运算符,也可以是复杂的逻辑表达式。而otherwise语句是可选的,它用于处理所有的条件都不满足时的逻辑。 选择语句的执行是有顺序的,当某个when语句的条件满足时,它的逻辑块会被执行,而之后的所有when和otherwise语句都会被忽略。因此,当存在多个满足条件的when语句时,只会执行第一个满足条件的when逻辑块。 通过使用选择语句,我们可以根据不同的条件执行不同的逻辑,从而提高程序的灵活性和可读性。当需求需要根据不同条件执行不同逻辑时,选择语句是一个非常好的解决方案。而MyBatis提供的choose、when和otherwise关键字能够很方便地实现选择语句的功能。 ### 回答3: MyBatis 中的 choose、when、otherwise 用于处理多个条件的选择语句。 在进行数据检索时,我们经常会有多个条件需要进行判断,根据不同的条件选择不同的 SQL 语句执行。 在 MyBatis 中使用 choose、when、otherwise 进行条件选择,通常的语法结构如下: ``` <choose> <when test="condition1"> <!-- SQL1 --> </when> <when test="condition2"> <!-- SQL2 --> </when> <otherwise> <!-- SQL3 --> </otherwise> </choose> ``` - `<choose>` 是选择语句的的起始标签。 - `<when>` 是条件判断的标签。当条件满足时,会执行对应的 SQL 语句。 - `<otherwise>` 是当所有的条件都不满足时,会执行的标签。 - `test` 表达式用于判断是否满足条件。可以根据参数的值、对象的属性等来进行判断。 在实际使用时,可以根据具体的需求对条件进行判断,可以使用多个 `<when>` 进行多个条件的判断。 在选择语句中,最多只会有一个分支被执行。当某个条件满足时,会执行对应的 SQL 语句,并结束整个 choose 语句块。 当所有的条件都不满足时,会执行 `<otherwise>` 标签中的 SQL 语句。 通过使用 choose、when、otherwise,可以实现根据多个条件进行选择的功能,避免了编写复杂的 IF ELSE 语句。这种方式使得 SQL 语句的编写更加灵活和可读性更高。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值