原先有一段时间在整合SpringBoot和Flink1.10上花了一些时间,结果以失败告终。中间碰到很多问题。
把目前能记住印象最深的记录下:

1.log4j2和logback jar包冲突问题。

出错当时没有截图,哎,有点遗憾…

把Flink任务放到Yarn集群上运行时会出类似错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/zhanggong004/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/zhanggong004/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/C:/Users/zhanggong004/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactoryat org.springframework.util.Assert.instanceCheckFailed(Assert.java:655)at org.springframework.util.Assert.isInstanceOf(Assert.java:555)at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:286)at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:102)at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:220)at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:199)at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260)at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248)at com.example.dubboconsumer.DubboConsumerApplication.main(DubboConsumerApplication.java:13)

解决方式很简单,全局排除spring-boot-starter-logging内的所有依赖

            <!--全局排除spring-boot-starter-logging内的所有依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId><exclusions><exclusion><groupId>*</groupId><artifactId>*</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-logging</artifactId></exclusion></exclusions></dependency>

2.jar打包工具

原先的打包工具用的是maven-assembly-plugin,目前发现,用这个插件打包springboot的项目生成的jar包和maven项目打成的jar包目录结构不一致,导致启动jar时启动不了,会出现各种神奇问题,还是没有截图,这就是事后诸葛亮的尴尬…

         <plugin><artifactId>maven-compiler-plugin</artifactId><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><artifactId>maven-assembly-plugin</artifactId><version>2.4</version><configuration><appendAssemblyId>false</appendAssemblyId><descriptorRefs><descriptorRef>jar-with-dependencies</descriptorRef></descriptorRefs></configuration><executions><execution><id>make-assembly</id><phase>package</phase><goals><goal>assembly</goal></goals></execution></executions></plugin>

后来看其他项目的时候,发现大数据项目打包工具普遍还是用maven-shade-plugin插件。

       <!--            maven-shade-plugin:创建项目的时候指定 Flink Quickstart Job类型,会自动在pom.xml添加这个plugin配置。--><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>3.2.1</version><executions><execution><phase>package</phase><goals><goal>shade</goal></goals><configuration><artifactSet><excludes><exclude>com.google.code.findbugs:jsr305</exclude><exclude>org.slf4j:*</exclude><exclude>log4j:*</exclude></excludes></artifactSet><filters><filter><!-- 不要拷贝 META-INF 目录下的签名,否则会引起 SecurityExceptions 。 --><artifact>*:*</artifact><excludes><exclude>META-INF/*.SF</exclude><exclude>META-INF/*.DSA</exclude><exclude>META-INF/*.RSA</exclude></excludes></filter></filters><transformers><!--AppendingTransformer,这两个配置是关键,会把spring相关的依赖、配置都打包到jar中--><transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/spring.handlers</resource></transformer><transformerimplementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer"><resource>META-INF/spring.factories</resource></transformer><transformerimplementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"><resource>META-INF/spring.schemas</resource></transformer><transformerimplementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/><transformerimplementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"><!-- mainClass:指定整个jar包的入口,不过其实关系不大,在上传到flink上之后,可以在submit job的时候再重新指定。--><mainClass>com.xxxx.xxxx.xxxx.xxxx.xxxx.FlinkTaskApplication</mainClass></transformer></transformers></configuration></execution></executions><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><version>2.1.5.RELEASE</version></dependency></dependencies></plugin>

springBoot 整合 Flink有很多坑,有成功经验的同学可以分享一下哦…

参考:

个人笔记Spring-boot 整合log4j2
https://blog.csdn.net/rainbow_lasia/article/details/107321034IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath,如何排除依赖冲突
https://blog.csdn.net/zhanggonglalala/article/details/88953345

SpringBoot整合log4j2相关推荐

  1. Springboot整合log4j2日志全解

    作者:上帝爱吃苹果 cnblogs.com/keeya/p/10101547.html 在项目推进中,如果说第一件事是搭Spring框架的话,那么第二件事情就是在Sring基础上搭建日志框架,我想很多 ...

  2. springboot整合log4j2报错Unexpected filename extension of file[file__E__classes_log4j2.yml].Should be .xm

    问题描述 今天通过springboot整合log4j2,坐标如下: <!-- log4j2 日志 --><dependency><groupId>org.sprin ...

  3. SpringBoot整合Log4j2以及配置详解

    文章目录 标题SpringBoot整合Log4j2以及配置详解 1.加入依赖 2.在src.java.main.resources目录下创建log4j2.xml文件 log4j2.xml文件内容如下: ...

  4. 关于springboot整合log4j2的史上最全配置解释

    说明:本文为作者原创,欢迎大家转载,不过记得声明出处哦~ 前言 日志管理在软件开发中必不可少,而Java开发中,log4j2以其简单易用的特点使其普及度非常高.但非常可惜的是log4j2的官方文档本人 ...

  5. SpringBoot—整合log4j2入门和log4j2.xml配置详解

    关注微信公众号:CodingTechWork,一起学习进步. 引言   对于一个线上程序或者服务而言,重要的是要有日志输出,这样才能方便运维.而日志的输出需要有一定的规划,如日志命名.日志大小,日志分 ...

  6. 第十一节:Springboot整合log4j2日志

    SpringBoot默认使用的是logback, 但是还有一个性能更高的日志实现框架log4j2. 为什么选用log4j2 相比与其他的日志系统,log4j2丢数据这种情况少:disruptor技术, ...

  7. springboot定时删除log4j_SpringBoot整合log4j2进行日志配置及防坑指南

    1.Log4j2优点 具体优点可以参考官方文档:https://logging.apache.org/log4j/2.x/ 我这边只简单说一下: 相比与其他的日志系统,log4j2丢数据的情况少:在多 ...

  8. log4j2 pattern 行号_Springboot整合log4j2日志全解总结

    在项目推进中,如果说第一件事是搭Spring框架的话,那么第二件事情就是在Sring基础上搭建日志框架,我想很多人都知道日志对于一个项目的重要性,尤其是线上Web项目,因为日志可能是我们了解应用如何执 ...

  9. SpringBoot 集成log4j2

    SpringBoot集成log4j2 1. Log4j2优点 2. Log4j2日志级别 2.1 级别 2.2 视图 3. SpringBoot整合Log4j2配置 4. log4j2.yml配置 1 ...

  10. logback日志pattern_Springboot整合log4j2日志全解

    点击上方"后端技术精选",选择"置顶公众号" 技术文章第一时间送达! 作者:上帝爱吃苹果 cnblogs.com/keeya/p/10101547.html 在 ...

最新文章

  1. 9.67最不下降子序列
  2. matlab根据 2 6,#2.6 应用MATLAB进行模型处理
  3. C#获取控制台句柄的方法
  4. numpy笔记:random.permutation
  5. boost::graph模块实现bellman-ford算法的测试程序
  6. SAP IBASE category 01 download
  7. python 快速排序_python-快速排序的两种方法
  8. 3123称重显示控制器说明书_失重秤在自动化配料系统中的应用 - 工业自动化称重仪表...
  9. python爬取系统_python应用:爬虫框架Scrapy系统学习第四篇——scrapy爬取笔趣阁小说...
  10. 解除劳动关系后,职工医保怎么续缴?
  11. 产品研发过程管理专题——编写软件测试计划需要考虑的几个问题
  12. mysql分析语句方法_Mysql分析-常用分析语句总结
  13. Android 仿qq 点赞功能
  14. 微信小程序弹框如何显示右上角的关闭
  15. OGRE实现天龙八部组合的骨骼动画
  16. 做一个小程序需要多少钱?
  17. 回顾一年的工作历程_但回首这一年来的工作经历
  18. python虚拟机管理系统_python 虚拟机 pdf
  19. conversion failed: could not load input document
  20. 期刊论文写作之【python matplotlib 画图设置】

热门文章

  1. EA游戏Battlefield 2(战地风云2) 单机地图简介
  2. ERNIE: Enhanced Representation through Knowledge Integration, Yu Sun 2020【representation+Bert+ner】
  3. Kaggle Tweet Sentiment Extraction竞赛
  4. ST7735 TFT显示屏 显示问题
  5. 深圳小汽车摇号结果采集
  6. 腾讯撕开中国NFT的“遮羞布”
  7. boost::object_pool使用
  8. 整数划分问题将正整数n表示成一系列正整数之和
  9. OpenDaylight(ODL)学习笔记
  10. 为什么中国没有诞生世界流行的编程语言?