java.lang.NoSuchMethodError:io.dropwizard.jersey.setup.JerseyEnvironment.getResourceConfig()Lcom/sun/jersey/api/core/ResourceConfig;
我试图访问一个遗留模块,并使用零代码框架编写集成测试。在集成测试模块中,我使用的是dropwizard-1.13.2版本,原始模块是0.7.1版本。使用时,我得到以下错误:java.lang.NoSuchMethodError:io.dropwizard.jersey.setup.JerseyEnvironment.getResourceConfig()Lcom/sun/jersey/api/core/ResourceConfig;,java,jersey,integration-testing,dropwizard,Java,Jersey,Integration Testing,Dropwizard,我试图访问一个遗留模块,并使用零代码框架编写集成测试。在集成测试模块中,我使用的是dropwizard-1.13.2版本,原始模块是0.7.1版本。使用时,我得到以下错误: java.lang.NoSuchMethodError: io.dropwizard.jersey.setup.JerseyEnvironment.getResourceConfig()Lcom/sun/jersey/api/core/ResourceConfig; at com.xyz.hubsystem.boo
java.lang.NoSuchMethodError: io.dropwizard.jersey.setup.JerseyEnvironment.getResourceConfig()Lcom/sun/jersey/api/core/ResourceConfig;
at com.xyz.hubsystem.bootstrap.ResourceConfig.bindResources(ResourceConfig.java:108)
at com.xyz.hubsystem.HubSystemApplication.run(HubSystemApplication.java:114)
at com.xyz.hubsystem.HubSystemApplication.run(HubSystemApplication.java:57)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:87)
at io.dropwizard.testing.DropwizardTestSupport.startIfRequired(DropwizardTestSupport.java:237)
at io.dropwizard.testing.DropwizardTestSupport.before(DropwizardTestSupport.java:151)
at io.dropwizard.testing.junit.DropwizardAppRule.before(DropwizardAppRule.java:159)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
答案如下:Dropwizard在
0.8版中迁移到Jersey 2
。您必须升级模块的代码或降级您正在使用的dropwizard
版本。stacktrace非常相似: