src*_*ulo 5 intellij-idea protocol-buffers maven protoc
我正在尝试在 intelij 中使用 protoc jar maven 插件。我已将此添加到我的 pom.xml 中:
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.1.0.2</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<includeDirectories>
<include>src/main/protobuf</include>
</includeDirectories>
<inputDirectories>
<include>src/main/protobuf</include>
</inputDirectories>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我有一个位于src/main/protobuf. 我的 pom.xml 中也有这个:
<dependency>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar</artifactId>
<version>3.1.0.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
这是原型:
package stringtest;
message StringObject {
repeated string string_one = 1;
repeated string string_two = 2;
repeated string string_three = 3;
}
Run Code Online (Sandbox Code Playgroud)
但是,无论何时我右键单击我的模块并单击构建,或者如果我转到构建菜单并点击构建项目,我都看不到正在生成任何已编译的 protobuf 文件。我也没有看到任何错误。有谁知道我做错了什么?
小智 0
确保您的 .proto 文件位于资源文件夹 src/main/resources 中,并且当您运行 maven install 时,您的 pom.xml 可以位于 src 文件夹中的任何位置。您应该会看到主 java 文件夹中生成了文件。