java - 如何在thrift中使用PHP和JAVA

标签 java php ubuntu-12.04 thrift

我已经在 Ubuntu 12.04 中安装了 thrift 0.8.0
我正确地遵循了所有命令,没有任何错误,但安装后它工作完美

现在我想通过 thrift 使用 PHP,但在下面的代码中,它只对 C++ 和 Python 显示"is",我需要 java 和 PHP,但这两种语言显示“否”,我如何在 thrift 中使用 PHP 和 java,有吗?有java和php的库吗?

thrift 0.8.0

Building code generators ..... :

Building C++ Library ......... : yes
Building C (GLib) Library .... : no
Building Java Library ........ : no
Building C# Library .......... : no
Building Python Library ...... : yes
Building Ruby Library ........ : no
Building Haskell Library ..... : no
Building Perl Library ........ : no
Building PHP Library ......... : no
Building Erlang Library ...... : no
Building Go Library .......... : no

Building TZlibTransport ...... : yes
Building TNonblockingServer .. : yes

Using Python ................. : /usr/bin/python

最佳答案

首先,下载Thrift的源码版本。如果可能的话,我强烈建议使用较新的版本。有多种方法可以包含 Thrift Java 库(可能需要根据您的 Thrift 版本稍作更改):

如果你使用maven,你可以将maven坐标添加到你的pom.xml中:

<dependency>
    <groupId>org.apache.thrift</groupId>
    <artifactId>libthrift</artifactId>
    <version>0.9.1</version>
</dependency>

或者,您也可以直接下载 JAR 并将其添加到您的项目中:

http://central.maven.org/maven2/org/apache/thrift/libthrift/0.9.1/libthrift-0.9.1.jar

如果您使用的版本尚未发布到中央 Maven 存储库,您可以下载源 tarball 并导航到 lib/java 目录,并通过键入以下内容使用 Apache Ant 构建它:

ant

库 JAR 将位于 lib/java/build 目录中。您可以选择将新构建的 JAR 添加到本地 Maven 存储库:

mvn install:install-file -DartifactId=libthrift -DgroupId=org.apache.thrift -Dvers

对于 PHP 库,导航至 lib/php/src 目录并将 PHP 文件复制到您的项目中。然后,您可以使用 Thrift\ClassLoader\ThriftClassLoader 类或 autoload.php 脚本来包含 Thrift PHP 库。除非您尝试使用实现 thrift 协议(protocol)的 native PHP 扩展,否则无需构建。

关于java - 如何在thrift中使用PHP和JAVA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26093807/

相关文章:

java - IntelliJ 15 运行缓慢并占用 1GB 内存

PHP PDO 自定义类返回一个对象而不是它应该返回的对象

php - 如何在 PHP 中解码具有多个对象的 JSON 字符串?

php - php中的fetch有什么作用?

linux - 安装 insights 时出错(安装 bower){ OpenEdX,Ubuntu Server 12.04 }

c - 在C中的不同文件中获取标准输出和错误输出

ruby - 如何在没有 RVM 的情况下在 Ubuntu 上安装 Ruby 2

Java:检查arraylist是否是斐波那契数列的一部分

java - 为什么我得到 java.io.FileNotFoundException : http://10. 0.2.2 :4000/products/add when trying to send http request?

java - 在 jsf 中使用 ArrayDataModel 向数据表添加一行?