Splitter blows up on simple Pattern

后端 未结 3 1395
南笙
南笙 2020-12-19 04:21

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 =         


        
相关标签:
3条回答
  • 2020-12-19 04:42

    The java.lang.NoSuchMethodError tells you that the desired method is missing in the current runtime classpath while it was there in the compile time classpath.

    In other words, to fix this problem you need to align your runtime classpath to have the correct version of the API as you used during compile time. It can also be caused by having different versions of the library mixed throughout the runtime classpath. Cleanup the classpath then.

    0 讨论(0)
  • 2020-12-19 04:44

    Actually. you got two version of com.google.common.base.Platform class and one of these classes has or hasn't the method.

    Try to remove one of the jar files. I suggest to remove google-collections.jar and leave gauva.jar.

    It will work fine.

    0 讨论(0)
  • 2020-12-19 04:50

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

    Edit: 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.

    0 讨论(0)
提交回复
热议问题