【问题标题】:how to exclude in maven the slf4j for hector如何在 Maven 中排除赫克托的 slf4j
【发布时间】:2012-07-16 05:01:54
【问题描述】:

在 maven 依赖项中,我添加了 hector 来评估 Cassandra

<dependency>
   <groupId>org.hectorclient</groupId>
   <artifactId>hector-core</artifactId>
   <version>1.1-0</version>
</dependency>

并获得以下 logback 消息

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/yulia/.m2/repository/org/slf4j/slf4j-  log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/yulia/.m2/repository/ch/qos/logback/logback-classic/0.9.24/logback-classic-0.9.24.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

如何从 hector 依赖项中排除 slf4j ?

【问题讨论】:

  • 你是在使用 Maven 添加 slf4j 的依赖吗?
  • 不,我在 maven 中添加 hectorclient 时出现此错误。当我从 maven 中删除 hector-client 时,logback 又开始工作了

标签: java cassandra hector


【解决方案1】:

你可以这样做 -

<dependency>
   <groupId>org.hectorclient</groupId>
   <artifactId>hector-core</artifactId>
   <version>1.1-0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
</dependency>

【讨论】:

  • 我已添加,但这无济于事。我在依赖项中看到:org.hectorclient:hector-core -> org.apache.cassandra:cassandra-all -> org.slf4j
  • 什么是 slf4j jar 名称确切名称
【解决方案2】:

我找到了:-)!

应该如下:

<dependency>
        <groupId>org.hectorclient</groupId>
        <artifactId>hector-core</artifactId>
        <version>1.1-0</version>
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

这个依赖来自cassandra-all

【讨论】:

    猜你喜欢
    • 2013-07-10
    • 2013-10-28
    • 2012-07-16
    • 2012-02-23
    • 2018-10-19
    • 2012-07-19
    • 1970-01-01
    • 2011-09-17
    • 1970-01-01
    相关资源
    最近更新 更多