java - 为什么我需要排除“spring-boot-starter-logging”才能使用spring-geode?
问题描述
为了能够使用 spring-geode,我需要排除 starter-logging,否则我会遇到:
Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLogger cannot be cast to org.apache.logging.log4j.core.Logger
at org.apache.geode.internal.logging.LogService.init(LogService.java:81) ~[geode-core-1.2.1.jar:na]
at org.apache.geode.internal.logging.LogService.<clinit>(LogService.java:72) ~[geode-core-1.2.1.jar:na]
... 41 common frames omitted
我的 POM 现在看起来像这样:
<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>
<dependency>
<groupId>org.springframework.geode</groupId>
<artifactId>spring-geode-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-geode</artifactId>
<version>2.0.10.RELEASE</version>
</dependency>
我该怎么办?
解决方案
Geode 引入了与 Spring 日志记录冲突的日志记录依赖项 (log4j): https ://mvnrepository.com/artifact/org.apache.geode/geode-core/1.7.0
请参见https://lists.apache.org/thread.html/311d0e4bf742a2477f337f1028bdf991d16560c1bb0e7cd0f0ea9c1d@<user.geode.apache.org>
Spring 默认使用 Logback。您需要将日志框架更改为 log4j https://docs.spring.io/spring-boot/docs/current/reference/html/howto-logging.html#howto-configure-log4j-for-logging
推荐阅读
- laravel - Vue.js + vue-router + axios + Laravel。无法按 id 检索值
- node.js - npm install node-sass@3.7.0 生成 -Wrange-loop-analysis 问题
- c# - 比较两个 System.Type 是否相等失败?
- ios - 是否可以在“最近通话”或“通话信息”屏幕中添加应用功能?
- android - 如何从警报对话框中获取值并设置为 Flutter 中的按钮?
- c# - 如何通过代码向 bindingnavigator 添加按钮以及如何隐藏和/或禁用默认按钮?C#
- android - 如何查看 Android Studio 用于安装 apk 的 gradle 任务?
- python - Conda 的 requirements.txt 没有正确安装
- powerbi - DAX/Power BI:如何有条件地在两列(或更多列)上过滤不同的行?
- regex - 在字符串中搜索某些单词