Maven插件报错——protobuf-maven-plugin

2020-01-15  本文已影响0人  李小二的倔强

错误如下:

G:\develop\jdk\bin\java.exe -Dmaven.multiModuleProjectDirectory=H:\grpc-parent\grpc-parent\grpc-lib -Dmaven.home=G:\develop\maven\apache-maven-3.6.1 -Dclassworlds.conf=G:\develop\maven\apache-maven-3.6.1\bin\m2.conf "-javaagent:D:\Intellij\IntelliJ IDEA 2019.1.3\lib\idea_rt.jar=62499:D:\Intellij\IntelliJ IDEA 2019.1.3\bin" -Dfile.encoding=UTF-8 -classpath G:\develop\maven\apache-maven-3.6.1\boot\plexus-classworlds-2.6.0.jar org.codehaus.classworlds.Launcher -Didea.version2019.1.3 -s G:\develop\maven\apache-maven-3.6.1\conf\settings.xml -DskipTests=true install
[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.zzsz:grpc-lib:jar:0.0.1-SNAPSHOT
[WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-compiler-plugin @ line 122, column 12
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO] ------------------------------------------------------------------------
[INFO] Detecting the operating system and CPU architecture
[INFO] ------------------------------------------------------------------------
[INFO] os.detected.name: windows
[INFO] os.detected.arch: x86_64
[INFO] os.detected.version: 10.0
[INFO] os.detected.version.major: 10
[INFO] os.detected.version.minor: 0
[INFO] os.detected.classifier: windows-x86_64
[INFO] 
[INFO] -------------------------< com.zzsz:grpc-lib >--------------------------
[INFO] Building grpc-lib 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- protobuf-maven-plugin:0.5.0:compile (default) @ grpc-lib ---
[INFO] Compiling 2 proto file(s) to H:\grpc-parent\grpc-parent\grpc-lib\src\main\java
[ERROR] PROTOC FAILED: google/api/annotations.proto: File not found.
com/zzsz/pid.proto: Import "google/api/annotations.proto" was not found or had errors.

[ERROR] H:\grpc-parent\grpc-parent\grpc-lib\src\main\proto\com\zzsz\pid.proto [0:0]: google/api/annotations.proto: File not found.
com/zzsz/pid.proto: Import "google/api/annotations.proto" was not found or had errors.

[ERROR] H:\grpc-parent\grpc-parent\grpc-lib\src\main\proto\com\zzsz\user.proto [0:0]: google/api/annotations.proto: File not found.
com/zzsz/pid.proto: Import "google/api/annotations.proto" was not found or had errors.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.672 s
[INFO] Finished at: 2020-01-15T15:29:02+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.xolstice.maven.plugins:protobuf-maven-plugin:0.5.0:compile (default) on project grpc-lib: protoc did not exit cleanly. Review output for more information. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

Process finished with exit code 1

插件如下:

            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.5.0</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}-1:exe:${os.detected.classifier}
                    </protocArtifact>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:0.15.0:exe:${os.detected.classifier}</pluginArtifact>
                    <pluginId>grpc</pluginId>
                    <protoSourceRoot>src/main/proto</protoSourceRoot>
                    <!-- 默认值 -->
                    <outputDirectory>${project.build.sourceDirectory}</outputDirectory>
                    <!-- 设置是否在生成java文件之前清空outputDirectory的文件,默认值为true,设置为false时也会覆盖同名文件 -->
                    <clearOutputDirectory>false</clearOutputDirectory>
                    <!-- 默认值 -->
<!--                    <temporaryProtoFileDirectory>${project.build.directory}/protoc-dependencies</temporaryProtoFileDirectory> -->
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

解决:

comile-javanano不支持service
需要使用compile-custom

上一篇下一篇

猜你喜欢

热点阅读