我正在尝试将 Sorm 用于游戏框架项目。我正在使用使用 Scala 2.10 的 2.1 版本。问题是我的课程没有被 Sorm 识别,我得到了一个ClassNotFoundException
这是我使用的:
package models
case class User(val name: String)
object Db extends Instance (
entities = Set(Entity[User]()),
url = "jdbc:h2:mem:test"
)
在我的控制器中:
import models.{Db,User}
object Application extends Controller {
def index = Action {
Db.save(User("test")) // Error at this line
Ok("saved")
}
}
还有一个例外:
play.api.Application$$anon$1: Execution exception[[ClassNotFoundException: models.User]]
at play.api.Application$class.handleError(Application.scala:279) ~[play_2.10.jar:2.1-RC1]
at play.api.DefaultApplication.handleError(Application.scala:373) [play_2.10.jar:2.1-RC1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$10$$anonfun$apply$27.apply(PlayDefaultUpstreamHandler.scala:296) [play_2.10.jar:2.1-RC1]
at play.core.server.netty.PlayDefaultUpstreamHandler$$anonfun$10$$anonfun$apply$27.apply(PlayDefaultUpstreamHandler.scala:294) [play_2.10.jar:2.1-RC1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
at play.api.libs.concurrent.PlayPromise$$anonfun$extend1$1.apply(Promise.scala:110) [play_2.10.jar:2.1-RC1]
Caused by: java.lang.ClassNotFoundException: models.User
at java.net.URLClassLoader$1.run(URLClassLoader.java:366) ~[na:1.7.0_09]
at java.net.URLClassLoader$1.run(URLClassLoader.java:355) ~[na:1.7.0_09]
at java.security.AccessController.doPrivileged(Native Method) ~[na:1.7.0_09]
at java.net.URLClassLoader.findClass(URLClassLoader.java:354) ~[na:1.7.0_09]
at java.lang.ClassLoader.loadClass(ClassLoader.java:423) ~[na:1.7.0_09]
at java.lang.ClassLoader.loadClass(ClassLoader.java:356) ~[na:1.7.0_09]
知道我怎样才能完成这项工作吗?