解决java.lang.NoClassDefFoundError: org/apache/log4j/Level
现象: java.lang.NoClassDefFoundError: org/apache/log4j/Level at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:230) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:112) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:275) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:248) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:261) at HttpUtils2.<clinit>(HttpUtils2.java:66)
原因其实是缺少log4j相关的jar,在classpath中加入log4j-1.2.14.jar即可解决问题。