如何从应用程序启动中删除 Spring Data CustomConversions 警告?

How to remove Spring Data CustomConversions warnings from application startup?

我有一个具有以下 Spring 依赖项的应用程序:

starterBase    : 'org.springframework.boot:spring-boot-starter:2.2.1.RELEASE',
starterActuator: 'org.springframework.boot:spring-boot-starter-actuator:2.2.1.RELEASE',
starterJpa     : 'org.springframework.boot:spring-boot-starter-data-jpa:2.2.1.RELEASE',
starterTest    : 'org.springframework.boot:spring-boot-starter-test:2.2.1.RELEASE',
starterWeb     : 'org.springframework.boot:spring-boot-starter-web:2.2.1.RELEASE',
elasticsearch  : 'org.springframework.boot:spring-boot-starter-data-elasticsearch:2.2.1.RELEASE'

在我添加elasticsearch依赖的那一刻,启动应用程序时出现如下警告:

WARN  [main] o.s.data.convert.CustomConversions.register - Registering converter from class org.springframework.data.geo.Point to interface java.util.Map as writing converter although it doesn't convert to a store-supported type! You might wanna check you annotation setup at the converter implementation.
WARN  [main] o.s.data.convert.CustomConversions.register - Registering converter from interface java.util.Map to class org.springframework.data.geo.Point as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.
WARN  [main] o.s.data.convert.CustomConversions.register - Registering converter from class org.springframework.data.elasticsearch.core.geo.GeoPoint to interface java.util.Map as writing converter although it doesn't convert to a store-supported type! You might wanna check you annotation setup at the converter implementation.
WARN  [main] o.s.data.convert.CustomConversions.register - Registering converter from interface java.util.Map to class org.springframework.data.elasticsearch.core.geo.GeoPoint as reading converter although it doesn't convert from a store-supported type! You might wanna check you annotation setup at the converter implementation.

我调试了代码,在CustomConversions.java中的spring-data-commons:2.2.1-RELEASE中,第196行有一个名为'register'的私有方法,它的 javadoc 提到了 Mongo 类型,这很奇怪,因为我们没有使用 Mongo。 Mongo 引用是否正确?

但主要问题是,有什么方法可以avoid/remove这些警告吗?

此代码于2017年4月重构为spring data commons,注释为原处复制,未做改编。所以这里没有 mongo 特定内容。

至于警告,您目前所能做的就是忽略它们,我们会检查是否需要这些。

加法:

an issue for that, the corrsponding PR 正在处理中。所以希望这些警告能尽快得到处理。

我通过添加到我的 application.yml:

修复了它
logging.level.org.springframework.data.convert.CustomConversions: ERROR

如果您使用 log4j2,您可以通过为此包添加特定的日志级别来忽略此错误,如下所示。

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Loggers>
        <Root level="info">
            <!-- <AppenderRef ref="........"/> -->
        </Root>

        <Logger name="org.springframework.data.convert.CustomConversions" level="ERROR"></Logger>
    </Loggers>

</Configuration>