保安的踩坑日记:

就是这样 无论怎么改怎么写 idea都无法解析 .proto文件中的service 这个名词
后来无意中查查查 发现第九行 message resourReq 多写了一遍 导致全文多了一个大括号 也就是说 service服务 一直在message的体里面 所以一直不能被idea resolve 被自己蠢死
附上一段meven的配置 如果maven的plugins中找不到protobuf的话 可能是没导包导致的
<build>
<!-- grpc-->
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.5.0.Final</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.5.1-1:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.17.1:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
本文记录了一次解决IDE无法解析.proto文件中service定义的问题经历,错误原因为message定义重复,导致语法错误。文中分享了正确的Maven配置,确保protobuf插件正确加载,帮助开发者避免类似陷阱。
2094

被折叠的 条评论
为什么被折叠?



