Splitter在简单模式上爆炸 [英] Splitter blows up on simple Pattern

查看:77
本文介绍了Splitter在简单模式上爆炸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Guava代替Google-Collections。斯普利特课看起来很酷。但是当我使用它时,像这样:

I am just starting to us Guava in place of Google-Collections. The Splitter class seemed cool. But when I use it, like this:

private static final Pattern p = Pattern.compile(" +");
private static final Splitter usSplitter = Splitter.on(p).trimResults();

我得到一个堆栈转储:

java.lang.NoSuchMethodError: com.google.common.base.Platform.precomputeCharMatcher(Lcom/google/common/base/CharMatcher;)Lcom/google/common/base/CharMatcher;
        at com.google.common.base.CharMatcher.precomputed(CharMatcher.java:662)
        at com.google.common.base.CharMatcher.<clinit>(CharMatcher.java:69)
        at com.google.common.base.Splitter.<init>(Splitter.java:99)
        at com.google.common.base.Splitter.on(Splitter.java:208)

javadocs对此com.google.common.base.Platform一无所知。所以有点难以猜出出了什么问题。

The javadocs have nothing about this "com.google.common.base.Platform." so its a bit hard to guess what is going wrong.

正如你所看到的,模式很简单。

As you can see, the Pattern is dead simple.

推荐答案

您使用的是什么版本的番石榴?这对r05来说非常合适。

What version of Guava are you using? This works perfectly fine for me with r05.

编辑:这里的具体问题似乎是你有google-collections和guava在运行时类路径中。 平台(内部类)存在于google-collections中,但没有 precomputedCharMatcher 方法。正在从番石榴罐中正确加载 Splitter ,但正在从google-collect jar加载 Platform

It seems like the specific issue here is that you have both google-collections and guava in your runtime classpath. Platform (an internal class) existed in google-collections but didn't have the precomputedCharMatcher method. Splitter is being loaded from the guava jar properly, but Platform is being loaded from the google-collect jar.

这篇关于Splitter在简单模式上爆炸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆