本文介绍了使用Guice 2.0的ClassNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 下面的代码使用Guice 2.0生成错误。有了Guice 1.0,一切都很好。 JDK是Java 6更新15。The code below generates an error using Guice 2.0. With Guice 1.0 everything is fine. The JDK is Java 6 update 15.public class App { public static void main(String[] args) { Guice.createInjector(new AbstractModule() { @Override protected void configure() { // just testing } }); }}错误是:Exception in thread "main" java.lang.NoClassDefFoundError: [Lorg/aopalliance/intercept/MethodInterceptor; at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2427) at java.lang.Class.getDeclaredMethods(Class.java:1791) at com.google.inject.internal.ProviderMethodsModule.getProviderMethods(ProviderMethodsModule.java:78) at com.google.inject.internal.ProviderMethodsModule.configure(ProviderMethodsModule.java:70) at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223) at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:232) at com.google.inject.spi.Elements.getElements(Elements.java:101) at com.google.inject.InjectorShell$Builder.build(InjectorShell.java:135) at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:102) at com.google.inject.Guice.createInjector(Guice.java:92) at com.google.inject.Guice.createInjector(Guice.java:69) at com.google.inject.Guice.createInjector(Guice.java:59) at App.main(App.java:6)Caused by: java.lang.ClassNotFoundException: org.aopalliance.intercept.MethodInterceptor at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:252) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320) ... 14 more可能是什么问题?推荐答案你错过了一个依赖jar ,类 org.aopalliance.intercept.MethodInterceptor 在类路径中。You have missed to include a dependency jar with the class org.aopalliance.intercept.MethodInterceptor in the classpath. 这篇关于使用Guice 2.0的ClassNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 19:43