程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> JAVA綜合教程 >> Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory,commonslogfactory

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

編輯:JAVA綜合教程

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


學習架構探險,從零開始寫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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved