如何为scala构建sorm 2.10.1

时间:2013-08-26 20:37:57

标签: scala maven sbt sorm

任何想法如何为scala构建SORM 2.10.1我正在尝试生成一个可以在我的eclipse项目中使用的jar文件。

这是我的代码

import sorm._
case class Coffee(name: String, supplier: Supplier, price: Double, sales: Int, total: Int)
case class Supplier(name: String, street: String, city: String, state: String, zip: String)

object Db extends Instance(
 entities = Set(Entity[Coffee](),Entity[Supplier])),url="jdbc:mysql://localhost:3306/db123")



object sormtest {

 import Db._
 def main(args: Array[String]): Unit = {
 val supplier1 = Supplier("Acme, Inc.", "99 Market Street", "Groundsville", "CA", "95199")
val supplier2 = Supplier("Superior Coffee", "1 Party Place", "Mendocino", "CA", "95460")
val supplier3 = Supplier("The High Ground", "100 Coffee Lane", "Meadows", "CA", "93966")


 Db.save(supplier2)  }}`

我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: com/mchange/v2/c3p0/impl/AbstractPoolBackedDataSource
    at sorm.core.Connector.<init>(Connector.scala:16)
    at sorm.Instance$Initialization.<init>(Instance.scala:209)
    at sorm.Instance.<init>(Instance.scala:29)
    at Db$.<init>(sormtest.scala:8)
    at Db$.<clinit>(sormtest.scala)
    at sormtest$.main(sormtest.scala:27)
    at sormtest.main(sormtest.scala)
Caused by: java.lang.ClassNotFoundException: com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 7 more

我已经从这里http://mvnrepository.com/artifact/org.sorm-framework/sorm/0.3.8

下载了jar文件

编辑: Maven存储库列出了要包含的许多jar文件。一旦我添加它们就解决了我的问题。

1 个答案:

答案 0 :(得分:3)

无需自行构建,SORM 0.3.8为available on Maven Central,并支持Scala 2.10.x。

SBT:

libraryDependencies += "org.sorm-framework" % "sorm" % "0.3.8"

的Maven:

<dependency>
    <groupId>org.sorm-framework</groupId>
    <artifactId>sorm</artifactId>
    <version>0.3.8</version>
</dependency>

如果你真的想要JAR,you can download it from there too