我使用Cassandra-Unit 3.1.3.2进行单元测试。
以下是我的代码段
EmbeddedCassandraServerHelper.startEmbeddedCassandra(EmbeddedCassandraServerHelper.CASSANDRA_RNDPORT_YML_FILE);
appConfig.setCassandraPort(EmbeddedCassandraServerHelper.getNativeTransportPort());
appConfig.setCassandraSession(Cluster.builder().addContactPoints(InetAddress.getByName("localhost").getHostAddress())
.withPort(54567).build().connect());
CqlSchemaInitializer cqlSchemaInitializer = new CqlSchemaInitializer(Arrays.asList("create_keyspace.cql"));
cqlSchemaInitializer.initialize(appConfig.getCassandraSession());
appConfig.setCassandraLodgingCommerceContentDao(new CassandraLodgingCommerceContentDao(appConfig.getCassandraSession()));
appConfig就是具有setter / getter的pojo。 我得到以下错误,
引起:java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) 在 sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:408) 在 com.datastax.driver.core.NettyUtil.newEventLoopGroupInstance(NettyUtil.java:134) ... 35更多引起:java.lang.NoSuchFieldError: DEFAULT_MAX_PENDING_TASKS at io.netty.channel.epoll.EpollEventLoop。(EpollEventLoop.java:84) 在 io.netty.channel.epoll.EpollEventLoopGroup.newChild(EpollEventLoopGroup.java:114) 在 io.netty.util.concurrent.MultithreadEventExecutorGroup。(MultithreadEventExecutorGroup.java:64) 在 io.netty.channel.MultithreadEventLoopGroup。(MultithreadEventLoopGroup.java:49) 在 io.netty.channel.epoll.EpollEventLoopGroup。(EpollEventLoopGroup.java:93) 在 io.netty.channel.epoll.EpollEventLoopGroup。(EpollEventLoopGroup.java:80) 在 io.netty.channel.epoll.EpollEventLoopGroup。(EpollEventLoopGroup.java:61) ......还有40多个
答案 0 :(得分:4)
添加以下依赖项后,它已解决
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.44.Final</version>