我正在使用Archlinux同时安装了Thrift 0.9.3和Apache。 在我的Netbeans项目中,当我import org.apache.thrift.*; 我得到“包org.apache.thrift不存在” 。 这个答案并没有解决问题,因为我没有/lib/java文件夹,也没有其他答案。 直到我无法在互联网上找到答案。 提前致谢。
I'm using Archlinux with both Thrift 0.9.3 and Apache installed. In my Netbeans project, when I import org.apache.thrift.*; I got "package org.apache.thrift does not exist". This answer didn't solved the problem because I got not /lib/java folder neither the other answer. Until the moment I couldn't find an answer on the internet. Thanks in advance.
最满意答案
您需要libthrift JAR文件才能使用Thrift编译器生成的Java代码。
如果您的项目设置为能够使用Maven存储库,则可以将此工件添加到项目中:
<dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.9.3</version> </dependency>或者,您可以从Maven central下载JAR文件并将其添加到您的项目中:
http://central.maven.org/maven2/org/apache/thrift/libthrift/0.9.3/libthrift-0.9.3.jar
另外需要注意的是,您使用的JAR版本应该与您用于代码生成的Thrift编译器的版本相匹配; 因此,如果升级用于项目的Thrift编译器,则还应升级JAR文件的版本。
You need the libthrift JAR file in order to use java code generated by the Thrift compiler.
If your project is set up to be able to use Maven repositories, you can add this artifact to your project:
<dependency> <groupId>org.apache.thrift</groupId> <artifactId>libthrift</artifactId> <version>0.9.3</version> </dependency>Alternatively you could just download the JAR file from Maven central and add it to your project:
http://central.maven.org/maven2/org/apache/thrift/libthrift/0.9.3/libthrift-0.9.3.jar
Also important to note is that the version of the JAR you use should match the version of the Thrift compiler that you use for code generation; so if you upgrade the Thrift compiler used for your project, you should upgrade the version of the JAR file as well.
更多推荐
发布评论