gpt4 book ai didi

scala - 将 jooq-sbt-plugin 与 ojdbc 一起使用

转载 作者:行者123 更新时间:2023-12-03 18:33:39 29 4
gpt4 key购买 nike

我正在使用 jOOQ .解决 jooq-sbt-plugin 的问题config ( here ) 导致了一个类路径问题,我认为该问题与原始问题不同。我设法让配置工作,但试图让它与 Oracle 驱动程序一起玩似乎是不可能的。

这里的问题是插件似乎运行自己的java进程,因此永远不会传递所需的类路径(其中包含 odbc14.jar)。有没有办法让插件工作?我不知道如何注入(inject)插件的类路径。

我能想出的唯一解决方法是定义一个任务(这里描述: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

最佳答案

jooq-sbt-plugin的自述文件说:

  • Add your database driver to your list of libraryDependencies with "jooq" scope:

    libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.22" % "jooq"


你漏掉了 Dependencies.two在上面的摘录中,但也许你错过了。

关于scala - 将 jooq-sbt-plugin 与 ojdbc 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18611727/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com