我正在使用jOOQ。解决jooq-sbt-plugin
配置问题(此处)导致了一个类路径问题,我认为该问题与原始问题不同。我设法让配置工作,但试图让它与 Oracle 驱动程序一起玩似乎是不可能的。
这里的问题是插件似乎运行自己的进程,因此永远不会传递java
所需的类路径(其中包含)。odbc14.jar
有没有办法让插件工作?我不知道如何注入插件的类路径。
我能想出的唯一解决方法是定义一个任务(此处描述:https ://gist.github.com/chris-martin/5140754 )。
任何帮助是极大的赞赏。谢谢。
2013-09-10 更新
这是配置:
import sbt._
import Keys._
import JOOQPlugin._
object SampleBuild extends Build {
lazy val all = Project(id = "all", base = file("."), settings = defaultSettings) aggregate(
one, two
)
lazy val one = Project(
id = "one",
base = file("one"),
settings = defaultSettings ++ Seq(
libraryDependencies ++= Dependencies.one
)
)
lazy val two = Project(
id = "two",
base = file("two"),
settings = defaultSettings ++ jooqSettings ++ customJooqSettings ++ Seq(
libraryDependencies ++= Dependencies.two
)
) dependsOn (one)
override lazy val settings = super.settings ++ buildSettings
lazy val buildSettings = Seq(
organization := "org.sample",
version := "0.1-SNAPSHOT",
scalaVersion := "2.10.2"
)
lazy val defaultSettings = Defaults.defaultSettings ++ Seq(
scalacOptions in Compile ++= scalacParams,
externalResolvers in Compile := Resolvers.commonResolvers,
shellPrompt := ShellPrompt.buildShellPrompt,
resolvers ++= Resolvers.commonResolvers
)
lazy val customJooqSettings = Seq(
jooqOptions := jooqBvpOptions,
jooqOutputDirectory := new java.io.File("../src/appdb/src/main/java")
)
lazy val jooqBvpOptions = Seq(
"jdbc.driver" -> "oracle.jdbc.OracleDriver",
"jdbc.url" -> "jdbc:oracle:thin:@//<some server>",
"jdbc.user" -> "<some user>",
"jdbc.password" -> "<some pwd>",
"generator.database.name" -> "org.jooq.util.oracle.OracleDatabase",
"generator.database.inputSchema" -> "<some schema>",
"generator.database.includes" -> "table1|table2|table3",
"generator.target.packageName" -> "org.example.generated")
}
object Resolvers { /* ... */ }
object Dependencies { /* ... */ }
object ShellPrompt { /* ... */ }
这是错误:
[info] Initialising properties : /jooq-config2705409947508036761.xml
[error] Cannot read /jooq-config2705409947508036761.xml. Error : oracle.jdbc.OracleDriver
[error] java.lang.ClassNotFoundException: oracle.jdbc.OracleDriver
[error] at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[error] at java.security.AccessController.doPrivileged(Native Method)
[error] at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[error] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[error] at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[error] at java.lang.Class.forName0(Native Method)
[error] at java.lang.Class.forName(Class.java:171)
[error] at org.jooq.util.GenerationTool.main(GenerationTool.java:269)
[error] at org.jooq.util.GenerationTool.main(GenerationTool.java:123)
[error] Usage : GenerationTool <configuration-file>
[trace] Stack trace suppressed: run last appdb-tool/jooq:codegen for the full output.
[error] (appdb-tool/jooq:codegen) Failed with return code: 255
[error] Total time: 1 s, completed Sep 10, 2013 1:45:24 PM