有没有一个Java接口Cassandra数据库,开箱即用? [英] Is there a Java interface to Cassandra database that works out of the box?

查看:308
本文介绍了有没有一个Java接口Cassandra数据库,开箱即用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中为Cassandra数据库设置了Hector API。我有
错误关于SLF4J [一些日志实用程序]。我花了最后
[几乎] 2小时调试错误。导入
软件包后,我得到

I set up the Hector API for Cassandra Database in Eclipse. I got errors about SLF4J [some logging utility]. I've spent the last [almost] 2 hours debugging errors with it. After importing the packages, I get


线程main中的异常java.lang.ExceptionInInitializerError at
org .slf4j.LoggerFactory.bind(LoggerFactory.java:128)at
org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279 )
在org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252)
org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265)at
me.prettyprint.cassandra。 service.AbstractCluster。(AbstractCluster.java:44)
at
me.prettyprint.cassandra.service.ThriftCluster。(ThriftCluster.java:21)
at
me.prettyprint。 hector.api.factory.HFactory.createCluster(HFactory.java:196)
at
me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:143)
at
me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:132)
在CassandraInterface.main(CassandraInterface.java:7)导致:
java.lang。 UnsupportedOperationException:此代码应该永远不会
进入jar在
org.slf4j.impl.StaticLoggerBinder(StaticLoggerBinder.java:63)
at
org.slf4j.impl .StaticLoggerBinder。(StaticLoggerBinder.java:44)
...另外11个

Exception in thread "main" java.lang.ExceptionInInitializerError at org.slf4j.LoggerFactory.bind(LoggerFactory.java:128) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:279) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:252) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:265) at me.prettyprint.cassandra.service.AbstractCluster.(AbstractCluster.java:44) at me.prettyprint.cassandra.service.ThriftCluster.(ThriftCluster.java:21) at me.prettyprint.hector.api.factory.HFactory.createCluster(HFactory.java:196) at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:143) at me.prettyprint.hector.api.factory.HFactory.getOrCreateCluster(HFactory.java:132) at CassandraInterface.main(CassandraInterface.java:7) Caused by: java.lang.UnsupportedOperationException: This code should have never made it into the jar at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:63) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:44) ... 11 more

有任何Cassandra数据库API可以直接进入我的
Eclipse项目并开始使用开箱即用,而无需
安装,配置和调试其他第三方软件?

Is there any Cassandra database API that I can just drop into my Eclipse project and begin using out of the box, without having to install, configure, and debug additional 3rd-party software?

另外:我没有安装Maven。最好的是单个
JAR文件或JAR文件/ java源文件夹。

Also: I don't have Maven installed. The best thing would be a single JAR file or folder of JAR files/java sources.

编辑:我安装了Hector API,错误,但现在我得到一个运行时错误

I have the Hector API installed and my program compiles without errors, but now I get a runtime error

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.thrift.meta_data.FieldValueMetaData.<init>(BZ)V
    at org.apache.cassandra.thrift.ColumnParent.<clinit>(ColumnParent.java:128)
    at me.prettyprint.cassandra.service.template.AbstractColumnFamilyTemplate.<init>(AbstractColumnFamilyTemplate.java:63)
    at me.prettyprint.cassandra.service.template.ColumnFamilyTemplate.<init>(ColumnFamilyTemplate.java:39)
    at me.prettyprint.cassandra.service.template.ThriftColumnFamilyTemplate.<init>(ThriftColumnFamilyTemplate.java:38)
    at CassandraInterface.main(CassandraInterface.java:66)

我需要.java,.class或.jar文件的任何组合,我可以放入我的项目,而不需要Maven或XML文件/目录配置任何一种。

I require any combination of .java, .class, or .jar files that I can just drop into my project without requiring Maven or XML file/directory configuration of any kind. Just something simple that does what it advertises.

推荐答案

在使用Eclipse时,为什么不使用内置的maven功能?这将允许您:

As you're using Eclipse, why not use the built-in maven functionality? This would allow you to:


...只需进入我的Eclipse项目,开始使用开箱即用,无需安装,配置和调试额外的第三方软件。

"...just drop into my Eclipse project and begin using out of the box, without having to install, configure, and debug additional 3rd-party software".

将以下内容放入pom.xml:

Place the following into your pom.xml:

      <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>1.6.4</version>
      </dependency>
      <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>1.6.4</version>
      </dependency>
      <dependency>
                <groupId>me.prettyprint</groupId>
                <artifactId>hector-core</artifactId>
                <version>1.0-4</version>
      </dependency>

您的代码应该可以正常工作。

Your code should then work.

强烈建议您查看为什么选择maven?有什么好处?

  • Maven Getting Started Guide
  • Eclipse & Maven Integration: Side by Side Plugin Comparison

最后,如果你不愿意走简单而相当标准的道路,您可以按照Nick的建议操作: https://github.com/rantav/hector/downloads 和下载包含所有jar的tar.gz,并将它们添加到您的类路径。

Finally, if you're unwilling to go the easy and fairly standard road, you can follow Nick's suggestion: https://github.com/rantav/hector/downloads and download the tar.gz that contains all of the jar's and add them to your classpath.

这篇关于有没有一个Java接口Cassandra数据库,开箱即用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆