0

尝试使用 Luminus 模板和 H2 db 从 Leiningen 创建简单的示例应用程序。没什么特别的,我确实看到很多这样做的例子,但总是得到No suitable driver.

lein new luminus guestbook +h2
cd guestbook
lein run
Syntax error (SQLException) compiling at (/private/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/form-init682714741074384097.clj:1:124).
No suitable driver

Full report at:
/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/clojure-2526208820906376199.edn

该文件包含:

{:clojure.main/message
 "Syntax error (SQLException) compiling at (/private/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/form-init682714741074384097.clj:1:124).\nNo suitable driver\n",
 :clojure.main/triage
 {:clojure.error/phase :compile-syntax-check,
  :clojure.error/line 1,
  :clojure.error/column 124,
  :clojure.error/source "form-init682714741074384097.clj",
  :clojure.error/path
  "/private/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/form-init682714741074384097.clj",
  :clojure.error/class java.sql.SQLException,
  :clojure.error/cause "No suitable driver"},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    "Syntax error compiling at (/private/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/form-init682714741074384097.clj:1:124).",
    :data
    {:clojure.error/phase :compile-syntax-check,
     :clojure.error/line 1,
     :clojure.error/column 124,
     :clojure.error/source
     "/private/var/folders/g2/tw6c1syn2hl_915p0xgc2hcm0000gn/T/form-init682714741074384097.clj"},
    :at [clojure.lang.Compiler load "Compiler.java" 7652]}
   {:type java.lang.RuntimeException,
    :message "could not start [#'guestbook.db.core/*db*] due to",
    :at [mount.core$up$fn__441 invoke "core.cljc" 80]}
   {:type java.lang.RuntimeException,
    :message
    "Failed to get driver instance for jdbcUrl=jdbc:postgresql://twcrone",
    :at
    [com.zaxxer.hikari.util.DriverDataSource
     <init>
     "DriverDataSource.java"
     114]}
   {:type java.sql.SQLException,
    :message "No suitable driver",
    :at [java.sql.DriverManager getDriver "DriverManager.java" 298]}],
  :trace
  [[java.sql.DriverManager getDriver "DriverManager.java" 298]
   [com.zaxxer.hikari.util.DriverDataSource
    <init>
    "DriverDataSource.java"
    106]
   [com.zaxxer.hikari.pool.PoolBase
    initializeDataSource
    "PoolBase.java"
    325]
   [com.zaxxer.hikari.pool.PoolBase <init> "PoolBase.java" 114]
   [com.zaxxer.hikari.pool.HikariPool <init> "HikariPool.java" 108]
   [com.zaxxer.hikari.HikariDataSource
    <init>
    "HikariDataSource.java"
    81]
   [hikari_cp.core$make_datasource invokeStatic "core.clj" 268]
   [hikari_cp.core$make_datasource invoke "core.clj" 265]
   [conman.core$connect_BANG_ invokeStatic "core.clj" 162]
   [conman.core$connect_BANG_ invoke "core.clj" 158]
   [guestbook.db.core$eval13387$fn__13388 invoke "core.clj" 10]
   [mount.core$record_BANG_ invokeStatic "core.cljc" 74]
   [mount.core$record_BANG_ invoke "core.cljc" 73]
   [mount.core$up$fn__441 invoke "core.cljc" 81]
   [mount.core$up invokeStatic "core.cljc" 80]
   [mount.core$up invoke "core.cljc" 78]
   [mount.core$bring invokeStatic "core.cljc" 247]
   [mount.core$bring invoke "core.cljc" 239]
   [mount.core$start invokeStatic "core.cljc" 289]
   [mount.core$start doInvoke "core.cljc" 281]
   [clojure.lang.RestFn invoke "RestFn.java" 397]
   [mount.core$start_with_args invokeStatic "core.cljc" 389]
   [mount.core$start_with_args doInvoke "core.cljc" 385]
   [clojure.lang.RestFn invoke "RestFn.java" 410]
   [guestbook.core$start_app invokeStatic "core.clj" 52]
   [guestbook.core$start_app invoke "core.clj" 51]
   [guestbook.core$_main invokeStatic "core.clj" 75]
   [guestbook.core$_main doInvoke "core.clj" 59]
   [clojure.lang.RestFn invoke "RestFn.java" 397]
   [clojure.lang.Var invoke "Var.java" 380]
   [user$eval18339 invokeStatic "form-init682714741074384097.clj" 1]
   [user$eval18339 invoke "form-init682714741074384097.clj" 1]
   [clojure.lang.Compiler eval "Compiler.java" 7181]
   [clojure.lang.Compiler eval "Compiler.java" 7171]
   [clojure.lang.Compiler load "Compiler.java" 7640]
   [clojure.lang.Compiler loadFile "Compiler.java" 7578]
   [clojure.main$load_script invokeStatic "main.clj" 475]
   [clojure.main$init_opt invokeStatic "main.clj" 477]
   [clojure.main$init_opt invoke "main.clj" 477]
   [clojure.main$initialize invokeStatic "main.clj" 508]
   [clojure.main$null_opt invokeStatic "main.clj" 542]
   [clojure.main$null_opt invoke "main.clj" 539]
   [clojure.main$main invokeStatic "main.clj" 664]
   [clojure.main$main doInvoke "main.clj" 616]
   [clojure.lang.RestFn applyTo "RestFn.java" 137]
   [clojure.lang.Var applyTo "Var.java" 705]
   [clojure.main main "main.java" 40]],
  :cause "No suitable driver",
  :phase :compile-syntax-check}}

我已经从其他示例中尝试了各种变体。

4

2 回答 2

2

关键是 edn 文件中的错误消息:它将问题数据库引用为“jdbcUrl=jdbc:postgresql://twcrone”。这不是 H2 数据库引用,因此您的 Luminus 项目(在类路径中只有 h2 驱动程序)会遇到问题。

于 2021-03-21T21:50:45.213 回答
1

lein new luminus guestbook +h2然后我就跑了cd guestbooklein run并且(在下载了很多库之后)它按预期启动了网络服务器,浏览http://127.0.0.1:3000显示 Luminus 网络应用程序。

您能否分享您采取的导致该错误的确切步骤?

于 2021-03-21T18:07:34.680 回答