我的lift sbt文件中有一个unmanagedClasspath条目,指向外部java项目的类。它编译得很好,但是当它运行时我得到一个NoClassDefError。下面是sbt条目,后跟一些NoClassDefError的痕迹。
任何帮助非常感谢
德
unmanagedClasspath in Compile += file("[Path to my project]/classes")
ERROR n.liftweb.http.provider.HTTPProvider - Failed to Boot! Your application may not run properly
java.lang.NoClassDefFoundError: com/myproject/MyClass
at bootstrap.liftweb.Boot.boot(Boot.scala:70) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_21]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_21]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_21]
at java.lang.reflect.Method.invoke(Method.java:601) ~[na:1.7.0_21]
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:364) ~[lift-util_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.util.ClassHelpers$$anonfun$createInvoker$1.apply(ClassHelpers.scala:362) ~[lift-util_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1999) ~[lift-webkit_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.http.DefaultBootstrap$$anonfun$boot$1.apply(LiftRules.scala:1999) ~[lift-webkit_2.9.1-2.5-RC2.jar:2.5-RC2]
at net.liftweb.common.Full.map(Box.scala:553) ~[lift-common_2.9.1-2.5-RC2.jar:2.5-RC2]
答案 0 :(得分:4)
unmanagedJars in Compile
用作Runtime
和Test
中相同密钥的基础,因此其内容由Runtime
继承,但unmanagedClasspath
不是这种情况。 1}}。这就是为什么你应该在可能的情况下选择unmanagedJars
。
您可以将文件夹明确添加到两种配置中:
val additionalClasses = file("[Path to my project]/classes")
unmanagedClasspath in Compile += additionalClasses
unmanagedClasspath in Runtime += additionalClasses
注意:sbt< 0.13不支持val
中的build.sbt
,因此您必须在两个设置中复制其内容,或切换为完整的Build.scala
。
有关类路径设置的功能以及配置之间的继承方式的详细信息,请参阅Classpaths docs和this anwser。
我想不出可以同时将它添加到两者的方法......