Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

学习架构探险,从零开始写Java Web框架时,在学习到springAOP时遇到一个异常:

"C:\Program Files\Java\jdk1.7.0_40\bin\java" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=D:\JetBrains\xxIntelliJ IDEA 2016.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.7.0_40\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\access-bridge.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_40\jre\lib\rt.jar;E:\GitCode\chapter1\target\classes;C:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.1.33\mysql-connector-java-5.1.33.jar;C:\Users\Administrator\.m2\repository\org\aopalliance\aopalliance.jar;C:\Users\Administrator\.m2\repository\asm\asm\2.2.3\asm-2.2.3.jar;C:\Users\Administrator\.m2\repository\asm\asm-commons\2.2.3\asm-commons-2.2.3.jar;C:\Users\Administrator\.m2\repository\cglib\cglib-nodep-2.2.2.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-aop\3.2.2.RELEASE\spring-aop-3.2.2.RELEASE.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-asm\3.1.0.RELEASE\spring-asm-3.1.0.RELEASE.jar;C:\Users\Administrator\.m2\repository\org\springframework\spring-core\3.2.2.RELEASE\spring-core-3.2.2.RELEASE.jar;D:\JetBrains\xxIntelliJ IDEA 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain springAop.Client
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.aop.framework.CglibAopProxy.<clinit>(CglibAopProxy.java:95)
at org.springframework.aop.framework.DefaultAopProxyFactory$CglibProxyFactory.createCglibProxy(DefaultAopProxyFactory.java:87)
at org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:62)
at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:105)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:98)
at springAop.Client.main(Client.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 11 more

Process finished with exit code 1

原因是:缺少commons-logging.jar包

解决方案:

①添加maven依赖:

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>

②下载jar包:http://files.cnblogs.com/files/hujinshui/commons-logging-1.2.zip

上一篇:用JQuery仿造QQ头像裁剪功能


下一篇:201521123111《Java程序设计》第13周学习总结