我是Skinny ORM的新手,我遇到了一个奇怪的问题。
我试图让一个小片段工作,SBT编译我的代码但是 我找不到运行时错误消息类。 (我收到的消息 通过Intellij运行
我的build.sbt:
name := "skinny_jdbc"
version := "1.0"
scalaVersion := "2.12.1"
libraryDependencies ++= Seq(
"org.skinny-framework" %% "skinny-orm" % "2.3.2",
"com.h2database" % "h2" % "1.4.+",
"ch.qos.logback" % "logback-classic" % "1.1.+"
)
我的测试应用
import scalikejdbc._
import skinny.orm._, feature._
import org.joda.time._
object sk_test extends App{
println ("In SK_test object")
skinny.DBSettings.initialize()
implicit val session = AutoSession
}
编译得很好 - 但我收到运行时错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/ObjectPool
详细信息如下。
先谢谢。
"C:\Program Files\Java\jdk1.8.0_66\bin\java" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\bin" -Dfile.encoding=UTF-8
-classpath "C:\Program Files\Java\jdk1.8.0_66\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\access-bridge-64.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\cldrdata.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\dnsns.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\jaccess.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\jfxrt.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\localedata.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunec.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunjce_provider.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunmscapi.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\javaws.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jce.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jfr.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_66\jre\lib\management-agent.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\plugin.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\resources.jar;
C:\Program Files\Java\jdk1.8.0_66\jre\lib\rt.jar;C:\Users\alpha\Desktop\Coursera\skinny_jdbc\target\scala-2.12\classes;C:\Users\alpha\.ivy2\cache\org.apache.commons\commons-pool2\jars\commons-pool2-2.4.2.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-orm_2.12\jars\skinny-orm_2.12-2.3.2.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-micro-common_2.12\jars\skinny-micro-common_2.12-1.2.1.jar;C:\Users\alpha\.ivy2\cache\org.skinny-framework\skinny-common_2.12\jars\skinny-common_2.12-2.3.2.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc_2.12\jars\scalikejdbc_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-syntax-support-macro_2.12\jars\scalikejdbc-syntax-support-macro_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-interpolation_2.12\jars\scalikejdbc-interpolation_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-interpolation-macro_2.12\jars\scalikejdbc-interpolation-macro_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-core_2.12\jars\scalikejdbc-core_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scalikejdbc\scalikejdbc-config_2.12\jars\scalikejdbc-config_2.12-2.5.0.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang.modules\scala-parser-combinators_2.12\bundles\scala-parser-combinators_2.12-1.0.4.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang\scala-reflect\jars\scala-reflect-2.12.1.jar;C:\Users\alpha\.ivy2\cache\org.scala-lang\scala-library\jars\scala-library-2.12.1.jar;C:\Users\alpha\.ivy2\cache\org.flywaydb\flyway-core\jars\flyway-core-4.0.3.jar;C:\Users\alpha\Desktop\Coursera\skinny_jdbc\lib\sqljdbc42.jar;C:\Users\alpha\.ivy2\cache\org.slf4j\slf4j-api\jars\slf4j-api-1.7.22.jar;C:\Users\alpha\.ivy2\cache\org.joda\joda-convert\jars\joda-convert-1.8.1.jar;C:\Users\alpha\.ivy2\cache\org.apache.commons\commons-dbcp2\jars\commons-dbcp2-2.1.1.jar;C:\Users\alpha\.ivy2\cache\joda-time\joda-time\jars\joda-time-2.9.6.jar;C:\Users\alpha\.ivy2\cache\commons-logging\commons-logging\jars\commons-logging-1.2.jar;C:\Users\alpha\.ivy2\cache\com.typesafe\config\bundles\config-1.3.1.jar;C:\Users\alpha\.ivy2\cache\com.h2database\h2\jars\h2-1.4.193.jar;C:\Users\alpha\.ivy2\cache\ch.qos.logback\logback-core\jars\logback-core-1.1.8.jar;C:\Users\alpha\.ivy2\cache\ch.qos.logback\logback-classic\jars\logback-classic-1.1.8.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 2016.3\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain sk_test
In SK_test object
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/pool/ObjectPool
at scalikejdbc.CommonsConnectionPoolFactory$.apply(CommonsConnectionPoolFactory.scala:16)
at scalikejdbc.CommonsConnectionPoolFactory$.apply(CommonsConnectionPoolFactory.scala:8)
at scalikejdbc.ConnectionPool$.add(ConnectionPool.scala:116)
at scalikejdbc.config.DBs.setup(DBs.scala:16)
at scalikejdbc.config.DBs.setup$(DBs.scala:10)
at skinny.SkinnyDBsWithEnv.setup(SkinnyDBsWithEnv.scala:9)
at scalikejdbc.config.DBs.$anonfun$setupAll$1(DBs.scala:21)
at scalikejdbc.config.DBs.$anonfun$setupAll$1$adapted(DBs.scala:21)
at scala.collection.immutable.List.foreach(List.scala:378)
at scalikejdbc.config.DBs.setupAll(DBs.scala:21)
at scalikejdbc.config.DBs.setupAll$(DBs.scala:19)
at skinny.SkinnyDBsWithEnv.setupAll(SkinnyDBsWithEnv.scala:9)
at skinny.DBSettingsInitializer.initialize(DBSettingsInitializer.scala:25)
at skinny.DBSettingsInitializer.initialize$(DBSettingsInitializer.scala:21)
at skinny.DBSettings$.initialize(DBSettings.scala:8)
at sk_test$.delayedEndpoint$sk_test$1(sk_test.scala:13)
at sk_test$delayedInit$body.apply(sk_test.scala:10)
at scala.Function0.apply$mcV$sp(Function0.scala:34)
at scala.Function0.apply$mcV$sp$(Function0.scala:34)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App.$anonfun$main$1$adapted(App.scala:76)
at scala.collection.immutable.List.foreach(List.scala:378)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at sk_test$.main(sk_test.scala:10)
at sk_test.main(sk_test.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)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.pool.ObjectPool
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)
... 31 more
答案 0 :(得分:0)
我相信您使用了网站上建议的application.conf。这应该可以正常工作。
development {
db {
default {
driver="org.h2.Driver"
url="jdbc:h2:file:./db/development;MODE=PostgreSQL;AUTO_SERVER=TRUE"
user="sa"
password="sa"
poolInitialSize=2
poolMaxSize=10
}
}
}
或者你必须在build.sbt中包含commons-dbcp以将库作为依赖项拉入