[英]maven project failed to execute “maven-thrift-plugin”
我在我的mac(0.11.0)和pom.xml中“brew install thrift”:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.thrift/libthrift -->
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.thrift.tools</groupId>
<artifactId>maven-thrift-plugin</artifactId>
<version>0.1.11</version>
<configuration>
<thriftExecutable>/usr/local/bin/thrift</thriftExecutable>
<thriftSourceRoot>src/main/java/thrift</thriftSourceRoot>
<outputDirectory>src/main/java/gen-java</outputDirectory>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>Maven Central Repository</id>
<name>Maven Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
然后是mvn包。 我想mvn應該自動下載我在pom.xml中為“maven-thrift-plugin:jar”指定的插件,但我得到了:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building java_local 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-thrift-plugin:0.1.11:compile (thrift-sources) @ java_local ---
[ERROR] thrift failed output:
[ERROR] thrift failed error: [FAILURE:generation:1] Error: unknown option java:hashcode
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.405 s
[INFO] Finished at: 2018-09-17T15:48:09+08:00
[INFO] Final Memory: 9M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.thrift.tools:maven-thrift-plugin:0.1.11:compile (thrift-sources) on project java_local: thrift 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
如何解決這個問題? 謝謝!
<version>0.11.0</version>
是依賴項的有效版本,但不是插件的有效版本。
將插件版本更改為<version>0.1.11</version>
。
然后運行mvn clean install
。
然后你的mvn package
命令應該工作。
嘗試在settings.xml
添加maven中央存儲庫:
<repositories>
<repository>
<id>Maven Central Repository</id>
<name>Maven Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
您還可以通過編輯POM來執行此項目特定的操作:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<dependencies>
...
</dependencies>
<repositories>
<repository>
<id>Maven Central Repository</id>
<name>Maven Central Repository</name>
<url>http://central.maven.org/maven2/</url>
</repository>
</repositories>
</project>
從插件版本0.1.10添加配置<generator>java</generator>
是修復問題
<plugin>
<groupId>org.apache.thrift.tools</groupId>
<artifactId>maven-thrift-plugin</artifactId>
<version>0.1.11</version>
<configuration>
<thriftExecutable>E:\path\to\thrift\thrift-0.12.0.exe</thriftExecutable>
<thriftSourceRoot>${basedir}/src/main/thrift</thriftSourceRoot>
<generator>java</generator>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>thrift-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.