NoSuchMethodError exception when using com.google.common.base.Splitter

前端 未结 7 2031
一个人的身影
一个人的身影 2021-01-17 07:38

I\'m trying to use com.google.common.base.Splitter as follows

Iterable segs = Splitter.on(\"/\").split(\"one/two/three/four/five\");

for (Stri         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 08:37

    Another reason this happens is if the GSON library is imported before the Guava library.

    See: https://github.com/google/guava/issues/2786

    I was importing the jars from a folder into IntelliJ. What ended up working was add a "z" next to gson (so the jar would be named zgson) so that Guava would import first.

提交回复
热议问题