开发者社区> 问答> 正文

Tair测试程序出现slf4j版本不兼容

我搭建的Tair平台,并且使用sbin/tairclient -c *:*.*.*5198 -g group_1客户端可以进行正常的读写,但是使用java client时总是出现如下的错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
    at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:141)
    at com.taobao.tair.impl.ConfigServer.retrieveConfigure(ConfigServer.java:156)
    at com.taobao.tair.impl.DefaultTairManager.init(DefaultTairManager.java:97)
    at com.java.tair.tair_example.TairClientTest.main(TairClientTest.java:28)
我的pom.xml的内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.alibaba.race</groupId>
    <artifactId>preliminary.demo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/main/resources/assembly.xml</descriptor>
                    </descriptors>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>install</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

<!--    com.alibaba.middleware.race.jstorm-2.1.1版本默认的日志框架是logback,为了避免日志冲突,排除掉log4j-->
    <dependencies>
        <dependency>
            <groupId>com.alibaba.rocketmq</groupId>
            <artifactId>rocketmq-client</artifactId>
            <version>3.2.6</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.alibaba.jstorm</groupId>
            <artifactId>jstorm-core</artifactId>
            <version>2.1.1</version>
            <!--            跑jstorm本地测试或者本地需要kryo相关操作时,请将provided屏蔽,
                        提交到jstorm集群的时候,记得加上provided的-->
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-nop</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-jdk14</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>com.taobao.tair</groupId>
            <artifactId>tair-client</artifactId>
            <version>2.3.4</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>
</project>

我在网络上查到是因为slf4j的版本不兼容导致的,但是我不知道该怎么更改,请问各位大神该怎么改呢?

展开
收起
小小付 2016-06-29 22:06:19 6250 0
4 条回答
写回答
取消 提交回答
  • ReTair测试程序出现slf4j版本不兼容
    经测试,可以在topology正常put,那么下一行代码就可以通过get并log出来测试是否正常写
    2016-06-30 19:39:30
    赞同 展开评论 打赏
  • 回 1楼小小付的帖子
    同样的问题 求赐教
    2016-06-30 18:47:51
    赞同 展开评论 打赏
  • 回 1楼小小付的帖子
    怎么解决的
    2016-06-29 22:51:50
    赞同 展开评论 打赏
  • ReTair测试程序出现slf4j版本不兼容
    已解决,可见已经用人出现过这样的问题了

    -------------------------

    ReTair测试程序出现slf4j版本不兼容
    <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.6.1</version>
        </dependency>

    统一回复一下:需要在pom.xml上加上如下依赖:

    2016-06-29 22:18:56
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
移动互联网测试到质量的转变 立即下载
给ITer的技术实战进阶课-阿里CIO学院独家教材(四) 立即下载
F2etest — 多浏览器兼容性测试整体解决方案 立即下载