我有一个Gradle依赖项目(比如 projectA ),为了调试它,它包含在另一个项目的类路径中(比如 rootProject )。 rootProject 扫描类路径并在运行时加载 projectA 。
当我运行 rootProject 时,它表示通过抛出java.lang.ClassNotFoundException
找不到 projectA 的依赖项。
java.lang.NoClassDefFoundError: org/glassfish/jersey/server/ResourceConfig
at be.vervaeck.sam.spongerest.RESTServer.<init>(RESTServer.java:18) ~[RESTServer.class:?]
at be.vervaeck.sam.spongerest.RESTServer.<init>(RESTServer.java:27) ~[RESTServer.class:?]
at be.vervaeck.sam.spongerest.SpongePlugin.onServerStart(SpongePlugin.java:25) ~[SpongePlugin.class:?]
at org.spongepowered.common.event.listener.GameStartedServerEventListener_SpongePlugin_onServerStart2.handle(Unknown Source) ~[?:?]
at org.spongepowered.common.event.RegisteredListener.handle(RegisteredListener.java:86) ~[RegisteredListener.class:?]
at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:238) [SpongeModEventManager.class:?]
at org.spongepowered.mod.event.SpongeModEventManager.post(SpongeModEventManager.java:282) [SpongeModEventManager.class:?]
at org.spongepowered.mod.SpongeMod.onStateEvent(SpongeMod.java:184) [SpongeMod.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:211) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:189) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_74]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_74]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_74]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_74]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.onPost(LoadController.java:53) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.serverStarted(Loader.java:800) [Loader.class:?]
at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarted(FMLCommonHandler.java:289) [FMLCommonHandler.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:510) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_74]
Caused by: java.lang.ClassNotFoundException: org.glassfish.jersey.server.ResourceConfig
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.12.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_74]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_74]
... 34 more
在Eclipse中,如何确保 projectA 的依赖项包含在 rootProject 的调试会话的类路径中?
答案 0 :(得分:0)
您可以在build.gradle中声明project dependency。例如:
project(':rootProject') {
dependencies {
compile project(':projectA')
}
}