【发布时间】:2012-11-25 03:04:19
【问题描述】:
我见过两个工具来生成兼容 finagle 的节俭。
thrift-0.5.0-finagle 是否太旧?最新的是 thrift 0.9。我还能用吗?
或者我应该使用Scrooge?它在 Scala 上生成一个 Java 绑定。
【问题讨论】:
标签: java generator thrift finagle
我见过两个工具来生成兼容 finagle 的节俭。
thrift-0.5.0-finagle 是否太旧?最新的是 thrift 0.9。我还能用吗?
或者我应该使用Scrooge?它在 Scala 上生成一个 Java 绑定。
【问题讨论】:
标签: java generator thrift finagle
如果您的项目是 Scala 或 Java,您应该使用 Scrooge。 thrift-0.5.0-finagle 已被弃用。
【讨论】:
你应该使用 Scrooge。 Scrooge 是由 Twitter 开发的。而且 Finagle 也是由 Twitter 开发的。
提示:
scrooge maven插件配置如下
<plugin>
<groupId>com.twitter</groupId>
<artifactId>scrooge-maven-plugin</artifactId>
<version>${scrooge.version}</version>
<configuration>
<thriftSourceRoot>${basedir}/src/main/thrift</thriftSourceRoot>
<includes>
<set>SyncWrite.thrift</set>
</includes>
<outputDirectory>${basedir}/src/main/gen/</outputDirectory>
<thriftNamespaceMappings>
<thriftNamespaceMapping>
<from>com.ganji.cdc.xapian.thrift.cpp</from>
<to>com.ganji.cdc.xapian.thrift.cpp</to>
</thriftNamespaceMapping>
</thriftNamespaceMappings>
<language>experimental-java</language>
<thriftOpts>
<thriftOpt>--finagle</thriftOpt>
</thriftOpts>
<buildExtractedThrift>false</buildExtractedThrift>
</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>
语言是
experimental-java。如果配置为 Scrooge 文档,使用java,libthrift库必须使用0.5.0。
有如下依赖库
<finagle.version>6.25.0</finagle.version>
<scrooge.version>3.18.1</scrooge.version>
<!-- Finagle Start -->
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-core_2.10</artifactId>
<version>${scrooge.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>scrooge-runtime_2.10</artifactId>
<version>${scrooge.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>util-core_2.10</artifactId>
<version>6.24.0</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>finagle-core_2.10</artifactId>
<version>${finagle.version}</version>
</dependency>
<dependency>
<groupId>com.twitter</groupId>
<artifactId>finagle-thrift_2.10</artifactId>
<version>${finagle.version}</version>
</dependency>
<!-- Finagle End -->
仅此而已。
【讨论】: