[英]ClassNotFoundException in sbt project
对于我的生活, 我的scala构建工具项目充满了ClassNotFoundExceptions。
我所要做的就是克隆它然后sbt run
而且我得到了
java.lang.NoClassDefFoundError: com/example/Utils$$anonfun$1
at com.example.Utils$.shortenTypeSignature(Utils.scala:10)
at com.example.Hello$.getTypedDeclaration$1(Hello.scala:69)
at com.example.Hello$.iterateThroughSourceFile$1(Hello.scala:113)
at com.example.Hello$.main(Hello.scala:157)
at com.example.Hello.main(Hello.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)
Caused by: java.lang.ClassNotFoundException: com.example.Utils$$anonfun$1
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at com.example.Utils$.shortenTypeSignature(Utils.scala:10)
at com.example.Hello$.getTypedDeclaration$1(Hello.scala:69)
at com.example.Hello$.iterateThroughSourceFile$1(Hello.scala:113)
以前,我必须在Hello.scala中插入一个GlobFinder
类型的变量,否则我会得到:
/*
Exception in thread "main" java.lang.NoClassDefFoundError: info/collaboration_station/utilities/GlobFinder
at info.collaboration_station.utilities.FileFinder.tryFindAbsolutePathOfFileWhoseNameIs(FileFinder.java:128)
at com.example.Hello$.main(Hello.scala:137)
at com.example.Hello.main(Hello.scala)
Caused by: java.lang.ClassNotFoundException: info.collaboration_station.utilities.GlobFinder
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)
... 3 more
*/
修复是添加此行...
val vvv = new GlobFinder("foo")
为什么我的Scala项目如此充满了ClassNotFoundExceptions?
我想我明白了。 该项目本身运行clean
。 它必须删除自己的类文件。
话虽这么说,删除clean
val proc = Runtime.getRuntime.exec(Array[String]("sbt", "clean", "set scalacOptions in ThisBuild ++= Seq(\\"-print\\")", "compile", "exit"))
^ Hello.scala中的^没有修复任何东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.