Here are some .protoc
files. The directory structure is as follows:
my-project
├── src
│ ├── main
│ │ ├── resource
│ │ │ └── exampleA.proto
│ │ │ └── exampleB.proto
├── pom.xml
and pom file as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<java.version>17</java.version>
<protoc.version>3.19.3</protoc.version>
<protobuf.plugin.version>0.6.1</protobuf.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${protoc.version}</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>${protoc.version}</version>
</dependency>
</dependencies>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.7.1</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>${protobuf.plugin.version}</version>
<extensions>true</extensions>
<configuration>
<!-- 工具版本 -->
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<!--默认值,proto源文件路径-->
<protoSourceRoot>${project.basedir}/src/main/resources</protoSourceRoot>
</configuration>
<executions>
<execution>
<goals>
<!--生成OuterClass类-->
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now I want to compile it into .java
file via maven built into IntelliJ Idea:
However, the following error occurs: protoc did not exit cleanly. Review output for more information
So guys, I have two questions:
- How to solve the garbled characters in the error log?
- How to solve this error?
Intellij Idea version is: IntelliJ IDEA 2024.3 (Ultimate Edition), and Maven version is: 3.9.9
-
Check whether IntelliJ IDEA is passing parameters like
-Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8
when executing Maven tasks. Also, verify that the console encoding in IDEA is correctly set to UTF-8.
You can right-click the task, select Modify Run Configuration, and adjust options such as VM Options, Maven Options, and Java Options as needed. -
Add the pluginArtifact information after , for example:
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.14.0:exe:${os.detected.classifier}</pluginArtifact>
NOTE: The specific version should be determined based on your environment.
3