我对幻影非常陌生,我对scala和cassandra有基本的了解。所以我试着用phantom做一个简单的crud例子,所以我在google上看了几个例子。最后我给出了这个例子。但是我运行这个代码不像这个项目自述文件所说的那样。我只是创建了一个intellij项目,有如下主要类。
import org.creative.document.dao.impl.{PhantomConnectorExample}
import org.creative.document.database.SongsDatabase
import org.creative.document.entity.Song
object DocumentAPIMain {
def main(args: Array[String]): Unit = {
val song = Song(songId,"Wahinnta Athnam gigum di","Pawana","Nanda Malini")
val songsDatabase = new SongsDatabase(PhantomConnectorExample.connector)
songsDatabase.saveOrUpdate(song)
}
}
这是我所做的唯一改变,除了所有的依赖项和上面提到的链接。
我已经创建了Cassandra键空间,歌曲表和歌曲由艺术家表手动。下面是我的 cassandra ·谢玛
CREATE KEYSPACE phantomtest WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
CREATE TABLE phantomtest.songs_by_artist (
artist text,
id timeuuid,
album text,
title text,
PRIMARY KEY (artist, id)
) WITH CLUSTERING ORDER BY (id ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
CREATE TABLE phantomtest.songs (
id timeuuid PRIMARY KEY,
album text,
artist text,
title text
) WITH bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
毕竟,当我运行main方法时,它将以以下错误结束
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/runtime/package$
at com.outworkers.phantom.column.AbstractColumn.com$outworkers$phantom$column$AbstractColumn$$_name(AbstractColumn.scala:55)
at com.outworkers.phantom.column.AbstractColumn.com$outworkers$phantom$column$AbstractColumn$$_name$(AbstractColumn.scala:54)
at com.outworkers.phantom.column.Column.com$outworkers$phantom$column$AbstractColumn$$_name$lzycompute(Column.scala:22)
at com.outworkers.phantom.column.Column.com$outworkers$phantom$column$AbstractColumn$$_name(Column.scala:22)
at com.outworkers.phantom.column.AbstractColumn.name(AbstractColumn.scala:58)
at com.outworkers.phantom.column.AbstractColumn.name$(AbstractColumn.scala:58)
at com.outworkers.phantom.column.Column.name(Column.scala:22)
at org.creative.document.database.SongsDatabase$anon$macro$1$1.store(SongsDatabase.scala:28)
at org.creative.document.database.SongsDatabase$anon$macro$1$1.store(SongsDatabase.scala:28)
at com.outworkers.phantom.CassandraTable.store(CassandraTable.scala:132)
at org.creative.document.database.SongsDatabase.saveOrUpdate(SongsDatabase.scala:28)
at org.creative.document.main.DocumentAPIMain$.main(DocumentAPIMain.scala:58)
at org.creative.document.main.DocumentAPIMain.main(DocumentAPIMain.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.runtime.package$
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
请帮我找出这个问题。我做错了什么。。。
1条答案
按热度按时间7ajki6be1#
我面临同样的问题,并添加了以下依赖项。
它对我有用。