【发布时间】:2021-01-08 18:20:44
【问题描述】:
我正在尝试关注这篇博文https://redbyte.eu/en/blog/calling-java-from-go-using-grpc/,并提供一个我最初尝试在此存储库https://github.com/khpeek/pdf-parser 中的工作示例。项目结构如下:
.
├── build
│ ├── extracted-include-protos
│ │ └── main
│ ├── extracted-protos
│ │ └── main
│ └── tmp
│ └── jar
│ └── MANIFEST.MF
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
└── main
└── proto
└── pdfparserapi.proto
build.gradle 如下:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
}
}
plugins {
id "com.google.protobuf" version "0.8.14"
id "java"
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:4.0.0-rc-2'
}
plugins {
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0'
}
}
generateProtoTasks {
all()*.plugins { grpc {} }
}
}
但是,如果我运行 ./gradlew build,我会收到以下错误:
> ./gradlew build
> Task :generateProto FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':generateProto'.
> Could not resolve all files for configuration ':protobufToolsLocator_protoc'.
> Could not resolve com.google.protobuf:protoc:4.0.0-rc-2.
Required by:
project :
> Could not resolve com.google.protobuf:protoc:4.0.0-rc-2.
> Could not get resource 'https://artifacts.apple.com/libs-release/com/google/protobuf/protoc/4.0.0-rc-2/protoc-4.0.0-rc-2.pom'.
> Could not GET 'https://artifacts.apple.com/libs-release/com/google/protobuf/protoc/4.0.0-rc-2/protoc-4.0.0-rc-2.pom'.
> artifacts.apple.com
> Could not resolve com.google.protobuf:protoc:4.0.0-rc-2.
> Could not get resource 'https://artifacts.apple.com/libs-snapshot/com/google/protobuf/protoc/4.0.0-rc-2/protoc-4.0.0-rc-2.pom'.
> Could not GET 'https://artifacts.apple.com/libs-snapshot/com/google/protobuf/protoc/4.0.0-rc-2/protoc-4.0.0-rc-2.pom'.
> artifacts.apple.com
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 908ms
3 actionable tasks: 3 executed
我不确定是什么导致了这个错误,因为我可以在 Maven Central (https://search.maven.org/artifact/com.google.protobuf/protoc/4.0.0-rc-2/pom) 上找到该版本的依赖项。知道如何解决这个问题吗?
(我观察到可能相关的一件事是 grpc 闭包是灰色的,如果我在 IntelliJ 中将鼠标悬停在它上面,我会看到消息
没有找到方法调用grpc的候选者。
【问题讨论】:
标签: java gradle protocol-buffers proto