Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

maven - java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument

I am trying to run this grpc-Java example on my local. Corresponding proto file for the same is here. When i try to run in on local it throws the following exception from here :

Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V
    at io.grpc.ServiceDescriptor.validateMethodNames(ServiceDescriptor.java:129)
    at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:83)
    at io.grpc.ServiceDescriptor.<init>(ServiceDescriptor.java:51)
    at io.grpc.ServiceDescriptor$Builder.build(ServiceDescriptor.java:219)
    at io.grpc.examples.helloworld.GreeterGrpc.getServiceDescriptor(GreeterGrpc.java:251)
    at io.grpc.examples.helloworld.GreeterGrpc$GreeterImplBase.bindService(GreeterGrpc.java:84)
    at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:125)
    at io.grpc.internal.AbstractServerImplBuilder.addService(AbstractServerImplBuilder.java:63)
    at com.cw.predictive.HelloWorldServer.start(HelloWorldServer.java:56)
    at com.cw.predictive.HelloWorldServer.main(HelloWorldServer.java:92)

This is my pom.xml as mentioned here :

 <dependencies>
         <dependency>
          <groupId>io.grpc</groupId>
          <artifactId>grpc-netty</artifactId>
          <version>1.1.2</version>
        </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-protobuf</artifactId>
        <version>1.1.2</version>
      </dependency>

      <dependency>
        <groupId>io.grpc</groupId>
        <artifactId>grpc-stub</artifactId>
        <version>1.1.2</version>
      </dependency>
  </dependencies>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
**Please add following dependencies in your project.**
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>23.6-jre</version>
</dependency> 
<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.8</version>
</dependency>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...