环境信息

Spring Boot 2.0.2 JDK 8, OS: windows 7

问题的提出

今天在开发中,碰到一下类似的错误信息:

15:44:09.198 INFO  com.jd.ai.cv.api.PubAPIApplication.logStarting@50 - Starting PubAPIApplication on ZB-PF0V10MN with PID 4324 (D:\CodeSpace\photobuyapi\target\classes started by chenjunfeng1 in D:\CodeSpace\photobuyapi)
15:44:09.203 DEBUG com.jd.ai.cv.api.PubAPIApplication.logStarting@53 - Running with Spring Boot v2.0.2.RELEASE, Spring v5.0.6.RELEASE
15:44:09.204 INFO  com.jd.ai.cv.api.PubAPIApplication.logStartupProfileInfo@659 - No active profile set, falling back to default profiles: default
15:44:09.252 INFO  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.prepareRefresh@590 - Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6422b7d4: startup date [Fri May 18 15:44:09 CST 2018]; root of context hierarchy
15:44:09.708 INFO  org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions@316 - Loading XML bean definitions from class path resource [spring-config-jmq.xml]
15:44:09.776 WARN  org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.refresh@558 - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [listener]
Offending resource: class path resource [spring-config-jmq.xml]
15:44:09.781 INFO  org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener.logAutoConfigurationReport@101 - Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
15:44:09.787 ERROR org.springframework.boot.SpringApplication.reportFailure@842 - Application run failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [listener]
Offending resource: class path resource [spring-config-jmq.xml]at org.springframework.beans.factory.parsing.FailFastProblemReporter.fatal(FailFastProblemReporter.java:62) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:90) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.parsing.ReaderContext.fatal(ReaderContext.java:68) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.NamespaceHandlerSupport.findParserForElement(NamespaceHandlerSupport.java:86) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1366) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1352) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:178) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:148) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:98) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:187) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:223) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:194) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.lambda$loadBeanDefinitionsFromImportedResources$0(ConfigurationClassBeanDefinitionReader.java:352) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) ~[?:1.8.0_144]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromImportedResources(ConfigurationClassBeanDefinitionReader.java:319) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:117) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:328) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]at com.jd.ai.cv.api.PubAPIApplication.main(PubAPIApplication.java:16) [classes/:?]at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_144]at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_144]at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_144]at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.2.RELEASE.jar:2.0.2.RELEASE]

好奇怪的问题呀……

问题的分析

其中的关键信息是:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionParser for element [listener]
Offending resource: class path resource [spring-config-jmq.xml]

从上述错误信息分析,可知问题在spring-config-jmq.xml文件中,这个是非常明显的。错误的问题是在解析Bean的时候出现的BeanDefinitionParsingException,原因是Confgiuration错误,元素错误,其中的一个元素是listener。
结合这个错误信息可知,listener这个节点在与某个Bean的解析中,发生了问题,至于是什么问题,需要结合配置文件来分析。
查看之后发现:

<jmq:listener topic="aifashion_producer" listener="consumertest" />
.......................
<jmq:consumer id="consumer" transport="jmq.transport" longPull="10000" pullTimeout="11000" autoStart="true">
<jmq:listener topic="@sys.jmq.product.topic.price@" listener="productPriceListener" maxConcurrent="10" minConcurrent="1" />
</jmq:consumer>

在上述配置中,可以发现listener节点竟然没有放在jmq:consumer节点中,所以导致了此问题的发生。真是汗颜呀,纯粹声明的时候晕了头……

总结

低级错误一个,但是基于异常信息来分析得出问题的大致根源和方向是最有价值的一件事情。

Spring Boot中Configuration problem: Cannot locate BeanDefinitionParser for element 的问题分析相关推荐

  1. Spring Boot中使用Spring-Retry重试框架

    文章目录 Spring Boot中使用Spring-Retry重试框架 Maven依赖 注解使用 开启Retry功能 注解`@Retryable` 注解`@Recover` 注解`@CircuitBr ...

  2. 【spring boot2】第8篇:spring boot 中的 servlet 容器及如何使用war包部署

    嵌入式 servlet 容器 在 spring boot 之前的web开发,我们都是把我们的应用部署到 Tomcat 等servelt容器,这些容器一般都会在我们的应用服务器上安装好环境,但是 spr ...

  3. 徒手解密 Spring Boot 中的 Starter自动化配置黑魔法

    我们使用 Spring Boot,基本上都是沉醉在它 Stater 的方便之中.Starter 为我们带来了众多的自动化配置,有了这些自动化配置,我们可以不费吹灰之力就能搭建一个生产级开发环境,有的小 ...

  4. Spring Boot 中关于 %2e 的 Trick

    作者 | Ruilin 来源 | http://rui0.cn/archives/1643 分享一个Spring Boot中关于%2e的小Trick. 先说结论,当Spring Boot版本在小于等于 ...

  5. Spring Boot中如何扩展XML请求和响应的支持

    在之前的所有Spring Boot教程中,我们都只提到和用到了针对HTML和JSON格式的请求与响应处理.那么对于XML格式的请求要如何快速的在Controller中包装成对象,以及如何以XML的格式 ...

  6. Spring Boot中使用RabbitMQ

    很久没有写Spring Boot的内容了,正好最近在写Spring Cloud Bus的内容,因为内容会有一些相关性,所以先补一篇关于AMQP的整合. Message Broker与AMQP简介 Me ...

  7. Spring Boot中使用Swagger2构建RESTful APIs

    关于 Swagger Swagger能成为最受欢迎的REST APIs文档生成工具之一,有以下几个原因: Swagger 可以生成一个具有互动性的API控制台,开发者可以用来快速学习和尝试API. S ...

  8. 在spring boot中集成Swagger

    Swagger 在spring boot中集成Swagger 新建一个swagger项目 maven依赖 <!-- https://mvnrepository.com/artifact/io.s ...

  9. springboot(三):Spring boot中Redis的使用

    转自www.ityouknow.com spring boot对常用的数据库支持外,对nosql 数据库也进行了封装自动化. redis介绍 Redis是目前业界使用最广泛的内存数据存储.相比memc ...

最新文章

  1. Ubuntu/Fedora高版本安装海思SDK的方法
  2. ssm java上传图片预览_ssm文件上传_上传图片
  3. git reset后本地拉取_Git 代码防丢指南
  4. STM32(一)----建立嵌入式STM32工程
  5. android imageview移动,基于Android实现随手指移动的ImageView
  6. 工具的使用——谷歌浏览器(chrome)
  7. close() was never explicitly called on database
  8. 根据xsd文件逆向生成java类
  9. pspice计算机仿真实验,基于OrCAD_PSpice二阶动态电路的计算机仿真分析
  10. 骁龙cpu linux内核,高通骁龙888 SoC在Linux 5.12内核才被支持,以往怎么兼容的?
  11. 2020-12.24 用SURF实现简易的两张图像拼接
  12. DVWA--SQL Injection(SQL注入-非盲注)(全难度)
  13. 开源工单系统 python_PESCMS Ticket 客服工单系统 v1.2.0 发布
  14. 2019年AI领域回顾:稳定发展还是幻想破灭?
  15. 仿速度装机联盟程序源码,装机联盟程序源码 安装联盟程序源码
  16. UltraISO制作的系统U盘详细教程
  17. sockboom群_Phonics:自然拼读自然拼读练习表
  18. (转)使用Excel批量给数据添加单引号和逗号
  19. 新闻列表案例(前端html,css)
  20. pyc和py文件的区别

热门文章

  1. 计算机使用的显示器有哪些重要参数,电脑显示器知识:显示器参数主要看什么?(2)...
  2. 命名----做程序员的基本要求
  3. 【雷达与对抗】【2018.05】用于调制信号分类的深度神经网络结构
  4. 2021寒假——洛谷刷题计划(35题)
  5. cpan mysql dbd_Perl中DBI、DBD::mysql模块的安装
  6. python函数测验题_python 函数练习题
  7. 嵌入式开发学习之--RCC(下)
  8. in-line(内联)概念
  9. 外观(Facade)模式
  10. access贝克曼_贝克曼库尔特ACCESS 2化学发光免疫分析仪