Recently in a PB version of the upgrade, The history of PB version is 2.4, is now intended to upgrade to 3.2, of course, PB version certainly has a lot of changes, it is no longer here to say, here is the key to say, the use of idea plug-in to facilitate the implementation of PB files Java compilation, so that, do not have to execute the command, while you can compile multiple PB files.
First step: Install the Plugin
Step Two: Configure the Pom file
<dependency> <groupId>com.google.protobuf</groupId> <artifactid>protobuf-java </artifactId> <version>3.1.0</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty</artifactId> < version>${grpc.version}</version> </dependency> <dependency> <groupId> io.grpc</groupid> <artifactId>grpc-protobuf</artifactId> <version>${ grpc.version}</version> </dependency> <dependency> <groupId>io.grpc< /groupid> <artifactId>grpc-stub</artifactId> <version>${grpc.version}</ Version> </dependency>
<Build> <Extensions> <extension> <groupId>Kr.motd.maven</groupId> <Artifactid>Os-maven-plugin</Artifactid> <version>1.4.1.Final</version> </extension> </Extensions> <Plugins> <plugin> <groupId>Org.xolstice.maven.plugins</groupId> <Artifactid>Protobuf-maven-plugin</Artifactid> <version>0.5.0</version> <Configuration> <protocartifact>Com.google.protobuf:protoc:3.1.0:exe:${os.detected.classifier}</protocartifact> <pluginID>Grpc-java</pluginID> <pluginartifact>Io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} </pluginartifact> </Configuration> <executions> <Execution> <Goals> <goal>Compile</goal> <goal>Compile-custom</goal> </Goals> </Execution> </executions> </plugin> </Plugins> </Build>
Step three: Create a proto file
The contents of the Person.proto file are as follows:
Syntax = "Proto3"= "Com.ptest.proto"= "Personmodel"; message person { = 1; = 2; = 3;}
Fourth step: Executing the MAVEN command (Protobuf:compile-javano)
Fifth step: Check the generated Java file (/target/generated-sources/protobuf/java/*)
Mac Idea Plugin--protobuf plugin