我有一个带有 Gradle 依赖项的项目(比如projectA),为了调试它,它包含在另一个项目的类路径中(比如rootProject)。rootProject扫描类路径并在运行时加载projectA。
当我运行rootProject时,它表示找不到 projectA的依赖项,方法是抛出一个java.lang.ClassNotFoundException
.
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的调试会话的类路径中?