zoukankan      html  css  js  c++  java
  • IDEA里运行代码时出现Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger的解决办法(图文详解)

      不多说,直接上干货!

     问题详情

      运行出现log4j的问题

    "C:Program FilesJavajdk1.8.0_66injava" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=D:SoftWareIntelliJ IDEAIntelliJ IDEA Community Edition 2016.1.4in" -Dfile.encoding=UTF-8 -classpath "C:Program FilesJavajdk1.8.0_66jrelibcharsets.jar;C:Program FilesJavajdk1.8.0_66jrelibdeploy.jar;C:Program FilesJavajdk1.8.0_66jrelibextaccess-bridge-64.jar;C:Program FilesJavajdk1.8.0_66jrelibextcldrdata.jar;C:Program FilesJavajdk1.8.0_66jrelibextdnsns.jar;C:Program FilesJavajdk1.8.0_66jrelibextjaccess.jar;C:Program FilesJavajdk1.8.0_66jrelibextjfxrt.jar;C:Program FilesJavajdk1.8.0_66jrelibextlocaledata.jar;C:Program FilesJavajdk1.8.0_66jrelibext
    ashorn.jar;C:Program FilesJavajdk1.8.0_66jrelibextsunec.jar;C:Program FilesJavajdk1.8.0_66jrelibextsunjce_provider.jar;C:Program FilesJavajdk1.8.0_66jrelibextsunmscapi.jar;C:Program FilesJavajdk1.8.0_66jrelibextsunpkcs11.jar;C:Program FilesJavajdk1.8.0_66jrelibextzipfs.jar;C:Program FilesJavajdk1.8.0_66jrelibjavaws.jar;C:Program FilesJavajdk1.8.0_66jrelibjce.jar;C:Program FilesJavajdk1.8.0_66jrelibjfr.jar;C:Program FilesJavajdk1.8.0_66jrelibjfxswt.jar;C:Program FilesJavajdk1.8.0_66jrelibjsse.jar;C:Program FilesJavajdk1.8.0_66jrelibmanagement-agent.jar;C:Program FilesJavajdk1.8.0_66jrelibplugin.jar;C:Program FilesJavajdk1.8.0_66jrelib
    esources.jar;C:Program FilesJavajdk1.8.0_66jrelib
    t.jar;D:CodeIntelliJIDEACodeHadoopSparkMllibAction	argetclasses;D:SoftWaremaven
    epositoryorgscala-langscala-library2.10.4scala-library-2.10.4.jar;C:Program FilesJavajdk1.8.0_66jre..lib	ools.jar;D:SoftWareIntelliJ IDEAIntelliJ IDEA Community Edition 2016.1.4libidea_rt.jar" com.intellij.rt.execution.application.AppMain zhouls.bigdata.chapter10.RunWordCount
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger
        at zhouls.bigdata.chapter10.RunWordCount$.main(RunWordCount.scala:12)
        at zhouls.bigdata.chapter10.RunWordCount.main(RunWordCount.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Logger
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more
    
    Process finished with exit code 1

     解决办法

       在项目的pom.xml里添加如下的配置信息

    <dependency>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
          <version>1.2.16</version>
          <scope>compile</scope>
     </dependency>

       当然,这版本,大家也可以选择个最新的稳定版本,我这里仅仅是个参考。

  • 相关阅读:
    数据库外连接和内连接详解
    关于省市联动问题的分析
    邮箱验证修改密码,通过邮箱找回密码
    格式化Json传递的日期
    项目中验证码的使用
    水仙花数
    回文数
    冒泡排序
    《终结者·洛谷小说》总集
    题解 CF151A 【Soft Drinking】
  • 原文地址:https://www.cnblogs.com/zlslch/p/7446555.html
Copyright © 2011-2022 走看看