我使用Dropwizard 8和Guice Bundle,当我想通过Guice Framework的@Provides
实例化一个创建actorSystem的类时,我遇到了这个例外:
1. java.lang.NoSuchMethodError: scala.collection.immutable.HashSet$.empty()Lscala/collection/immutable/HashSet;
2. java.lang.IllegalArgumentException: While attempting to resolve the dependencies of ma.cars.resources.AdResource errors were found
3. java.lang.IllegalStateException: Unable to perform operation: resolve on ma.cars.resources.AdResource
这是我的课程:
public class AdResource {
private ActorManager actorManager;
@Inject
public AdResource( ActorManager actorManager) {
this.actorManager = actorManager;
}
}
在我的模块中,我已经定义了一个提供ActorManager的方法:
@Provides
@LazySingleton
@Inject
public final ActorManager getActorManager(CarsConfiguration configuration, AdElasticDTOBuilder dtoBuilder) {
actorManager = new ActorManager(configuration);
return actorManager;
}
这是ActorManager
:
public ActorManager( CarsConfiguration conf,
AdElasticDTOBuilder dtoBuilder) {
this.system = ActorSystem.create("carsActorSystem");
}
调用create
方法时会抛出异常。
我使用Java 1.8.40 / intellij idea,gradle for dependcy injection和akka-actor 2.3.10。
以下是我的依赖项:
dependencies {
compile "io.dropwizard:dropwizard-core:0.8.1"
compile "io.dropwizard:dropwizard-client:0.8.1"
compile "io.dropwizard:dropwizard-hibernate:0.8.1"
compile "io.dropwizard:dropwizard-migrations:0.8.1"
compile "io.dropwizard.modules:dropwizard-java8:0.8.0-2"
compile "io.dropwizard.modules:dropwizard-java8-auth:0.8.0-2"
compile "com.h2database:h2:1.4.186"
compile group: 'com.vividsolutions', name: 'jts', version: '1.13'
compile group: 'net.coobird', name:'thumbnailator', version :'0.4.8'
compile group: 'com.nimbusds', name: 'nimbus-jose-jwt', version: '2.10.1'
compile group: 'org.mindrot', name: 'jbcrypt', version: '0.3m'
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.6'
compile group: 'com.typesafe.akka', name :'akka-actor_2.10', version :'2.3.10'
compile group: 'org.apache.commons', name :'commons-io', version :'1.3.2'
compile group: 'org.hibernate', name: 'hibernate-spatial', version: '4.3'
compile group: 'com.meltmedia.dropwizard', name: 'dropwizard-jest', version: '0.2.0-SNAPSHOT'
compile "de.thomaskrille:dropwizard-template-config:1.1.0"
compile "com.hubspot.dropwizard:dropwizard-guice:0.8.0"
compile("com.netflix.governator:governator:1.3.3") {
exclude group: 'com.google.guava', module: 'guava'
exclude group: 'commons-lang'
}
compile "org.jadira.usertype:usertype.extended:3.2.0.GA"
compile "com.newrelic.agent.java:newrelic-api:3.15.0"
compile("com.wordnik:swagger-jersey2-jaxrs_2.11:1.3.12") {
exclude group: 'org.glassfish.jersey.containers', module: 'jersey-container-servlet-core'
exclude group: 'org.glassfish.jersey.core', module: 'jersey-server'
exclude group: 'com.google.guava', module: 'guava'
}
testCompile "io.dropwizard:dropwizard-testing:0.8.1"
}
提前致谢,