【问题标题】:How to generate grpc java file in vscode using maven?如何使用maven在vscode中生成grpc java文件?
【发布时间】:2021-09-28 16:39:59
【问题描述】:

我注意到官方示例使用了一个名为 os-maven-plugin 的插件,它与 vscode 不兼容。

【问题讨论】:

  • 您需要描述您看到的错误/问题。只说“不兼容”是没有帮助的。
  • 如果你看过os-maven-plugin's document,你会发现这个插件只能在IDEAEclipse使用

标签: java grpc


【解决方案1】:

请改用protoc-jar-maven-plugin

            <plugin>
                <groupId>com.github.os72</groupId>
                <artifactId>protoc-jar-maven-plugin</artifactId>
                <version>3.11.4</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <protocArtifact>com.google.protobuf:protoc:3.17.3</protocArtifact>
                            <inputDirectories>
                                <include>src/main/proto</include>
                            </inputDirectories>
                            <outputTargets>
                                <outputTarget>
                                    <type>java</type>
                                    <outputDirectory>src/main/java</outputDirectory>
                                </outputTarget>
                                <outputTarget>
                                    <type>grpc-java</type>
                                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.39.0</pluginArtifact>
                                    <outputDirectory>src/main/java</outputDirectory>
                                </outputTarget>
                            </outputTargets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

【讨论】:

  • 这是唯一可以与 vscode 一起使用的插件吗?我们使用 maven 和 org.xolstice.maven.plugins :protobuf-maven-plugin 构建。它适用于从命令行构建的 maven,但生成的源目录在 vscode 中始终为空。
  • 是的,我认为是。我试过org.xolstice.maven.plugins :protobuf-maven-plugin,和你一样,还是不行……
猜你喜欢
  • 1970-01-01
  • 2016-02-19
  • 2019-05-12
  • 2020-03-05
  • 1970-01-01
  • 2022-08-02
  • 1970-01-01
  • 2016-12-05
  • 1970-01-01
相关资源
最近更新 更多