Exception in thread "main" java.lang.NoClassDefFoundError

在项目中,因为项目分成了好几个模块,各个模块之间相互调用其他模块的类中的方法, 开发时候一直遇到一个问题,就是找不到类,命名代码里面的包都已经有了,没有报错,但就是执行的时候报如下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: com/eng/score/Constant$
at com.rec.ItemBaseRecommand$.main(ItemBaseRecommand.scala:37)
at com.rec.ItemBaseRecommand.main(ItemBaseRecommand.scala)
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: com.eng.score.Constant$
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:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 7 more

Process finished with exit code 1

在rec 模块中依赖于score模块的类,在rec模块的  pom.xml中定义如下:



    
        com.allyes
        awiseeng-score
        ${awise-eng.score.version}
        provided
    


然后尝试将

provided

这一行去掉居然就可以了, 然后百度 provided到底意味着什么, provided意味着打包的时候可以不用包进去,事实上该依赖理论上可以参与编译,测试,运行等周期。相当于compile,但是在打包阶段做了exclude的动作

因为项目中这些模块是相互依赖的,不能设置成provided,去掉即可运行正常

如下:




maven相关的一些配置还是要多了解了解啊,太渣了


参考链接:

http://blog.csdn.net/kimylrong/article/details/50353161




你可能感兴趣的:(maven)