mysql scope runtime_Maven依赖scope属性详解-一个报错引发的问题 - 老郭种树
ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context
一
今天从Github下载一个spring boot项目,运行后报如上错误,详细如下:
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@63f509: startup date [Wed Jun 21 17:07:06 EDT 2017]; root of context hierarchy at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) [spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:954) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:961) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033) [spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:555) [spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE] at SpringBootExample.main(SpringBootExample.java:12) [classes/:na]
二、
1.解决
很头痛,对于spring boot的依赖。看上面报错日志,按道理应该是包重复了,我看了下maven的依赖树,没发现重复的,上次碰到这种情况是tomcat包依赖重复,感觉这次也是,因为按道理spring boot web里面有tomcat,感觉这次也是这种情况,然后我将如下依赖注释
org.springframework.boot
spring-boot-starter-tomcat
provided
还是同样错误,网上搜到同样情况
有人说将provided注释即可,试了下果然可以,很奇怪,然后搜了下 maven 中的用法。
2.拓展
scope英文中的意思是范围,从使用规则上看,也符合这翻译, scope不同的值代表相应jar包不同的使用范围。
我们知道依赖一个jar分为以下四种使用环节
编译
运行
测试
打包
而它的值分为以下几种:
compile 。默认不填就是compile
compile
和前面解决办法将scope注释一样,注释不填默认就是如上compile。此种情况,这个jar参与如上所有环节
test
这个值经常用在测试相关的jar包上
org.springframework.boot
spring-boot-starter-test
test
runntime
此属性表示该jar不参与编译,但是运行、测试和打包都会参与
mysql
mysql-connector-java
runtime
provided
此属性表示除了最后该jar不打包到项目中,其他前面几个环节都参与。其实就和compile差不多,但是却被exclusion了。通过这应该可以找出开始报错的原因了,看配置
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-tomcat
这里将spring boot里面自带的tomcat剔除了。然后又配置了
org.springframework.boot
spring-boot-starter-tomcat
provided
这里就很奇怪,因为spring-boot-starter里并没有tomcat,我们可以看看
为什么那里要exclusion,然后因为并没有依赖spring-boot-starter-web,所以其实这个工程是没有tomcat的,所以下面配置tomcat没啥毛病,但是可能provided并不参与打包,可能这里影响了整个项目的启动。
ok,虽然最后还有点疑问,但不影响问题解决。
No related posts.
mysql scope runtime_Maven依赖scope属性详解-一个报错引发的问题 - 老郭种树相关推荐
- Flink checkpoint操作流程详解与报错调试方法汇总,增量checkpoint原理及版本更新变化,作业恢复和扩缩容原理与优化
这里写目录标题 flink checkpint出错类型 flink 重启策略 Checkpint 流程简介 增量Checkpoint实现原理 MemoryStateBackend 原理 FsState ...
- yum命令详解和报错 Cannot find a valid baseurl for repo: base
文章目录 1 yum命令 1.1 yum简介 1.2 yum安装 1.3 yum配置 1.4 配置本地yum源 1.4.1 关于repo 文件的格式 1.5 配置国内yum源 1.5.1 上海交通大学 ...
- mysql创建表属性引_【学习之Mysql数据库】mysql数据库创建表的属性详解
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 MySQL中create table语句的基本语法是: CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name ...
- mysql disabled enabled_disabled与enabled是什么?disabled与enabled属性详解
本篇文章给大家带来的内容是关于disabled与enabled是什么?disabled与enabled属性详解,有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助. disabled与ena ...
- mysql启动参数(/etc/my.cnf)详解汇总
mysql启动参数(/etc/my.cnf)详解汇总 MYSQL–my.cnf配置中文详解 basedir = path 使用给定目录作为根目录(安装目录). character-sets-dir = ...
- 设计模式六大原则之里氏替换原则、依赖倒置原则详解
设计模式六大原则--里氏替换原则.依赖倒置原则详解 1.里氏代换原则(Liskov Substitution Principle) 概念 顾名思义,该原则用于经常发生替换的地方,在Java中指的是实现 ...
- spring依赖注入原理详解(转载)
spring依赖注入原理详解----转载 所谓依赖注入就是指:在运行期,由外部容器动态地将依赖对象注入到组件中.当spring容器启动后,spring容器初始化,创建并管理bean对象,以及销毁它.所 ...
- mysql 规则引擎_Drools规则引擎详解-常用的drl实例
package droolsDemo //说明:每个 drl 都必须声明一个包名,这个包名与 Java 里面的不同,它不需要与文件夹的层次结构一致, //主要用于可以根据kmodule.xml中不同的 ...
- java log4配置例子,log4j.properties配置属性详解与配置示例
log4j.properties配置属性详解与配置示例 发布时间:2018-03-27作者:laosun阅读(1535) log4j.properties配置属性详解与配置示例,拿走直接用!详细解答了 ...
最新文章
- Intel不挤牙膏了!10nm性能参数公布:提升43%
- Test 2018-09-19
- zcmu1550(字符串最小表示法)
- springmvc(18)使用WebSocket 和 STOMP 实现消息功能
- pthread和互斥量条件变量函数意义速查表
- 如何在MySQL中导入和导出数据库并重置root密码
- 阿德莱德大学招聘博士后研究员
- 带你了解Node.js包管理工具:包与NPM
- Java 并发编程阅读笔记
- 2018渭源县计算机老师,2018年甘肃定西渭源县选调教师公告【招60人】
- 【IT项目管理】第1章 走进IT项目管理
- 新周刊:放弃北上广的10个理由
- nvidia旧版驱动_鸡血驱动已发布,可新买的显卡打不上驱动?这事儿别急
- C#中的toolStrip控件
- numpy loadtxt错误ValueError: Wrong number of columns at line ***
- html页面增加分页符
- Python爬虫实战--(四)爬取58同城的商品数据
- 实现一个函数输入123456789,输出123,456,789”
- 大厂高频面试系列02--最长不重复子串问题(LeetCode)
- Android 万能适配器BaseQuickAdapter操作及免费源码