我试着在构思中使用羽毛笔,设置一切正常:
1 sbt相关性:
libraryDependencies ++= Seq(
"mysql" % "mysql-connector-java" % "8.0.17",
"io.getquill" %% "quill-jdbc" % "3.7.0"
)
2.应用程序属性(带我的参数):
ctx.dataSourceClassName=com.mysql.cj.jdbc.MysqlDataSource
ctx.dataSource.url=jdbc:mysql://host/database
ctx.dataSource.user=root
ctx.dataSource.password=root
ctx.dataSource.cachePrepStmts=true
ctx.dataSource.prepStmtCacheSize=250
ctx.dataSource.prepStmtCacheSqlLimit=2048
ctx.connectionTimeout=30000
我还没有找到在sbt项目中放置application.properties文件的位置,但是我在每个项目中都复制了它floder:the top 项目的floder,floder/src,floder/project,所以我认为它会起作用
3代码(使用mysql“world”数据库):
import io.getquill._
object A extends App{
lazy val ctx = new MysqlJdbcContext(SnakeCase, "ctx")
import ctx._
case class City(id: Int,name:String,countryCode:String,district:String,population:Int)
val q = quote {
query[City].filter(c => c.id > 1)
}
ctx.run(q)
}
但出现了错误:
[main] ERROR com.zaxxer.hikari.HikariConfig - HikariPool-1 - dataSource or dataSourceClassName or
jdbcUrl is required.
Exception in thread "main" java.lang.IllegalStateException: Failed to load data source for config:
'Config(SimpleConfigObject({}))'
at io.getquill.JdbcContextConfig.dataSource(JdbcContextConfig.scala:25)
at io.getquill.MysqlJdbcContext.<init>(MysqlJdbcContext.scala:14)
at io.getquill.MysqlJdbcContext.<init>(MysqlJdbcContext.scala:15)
at io.getquill.MysqlJdbcContext.<init>(MysqlJdbcContext.scala:16)
at A$.ctx$lzycompute(A.scala:5)
at A$.ctx(A.scala:5)
at A$.delayedEndpoint$A$1(A.scala:14)
at A$delayedInit$body.apply(A.scala:3)
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:388)
at scala.App.main(App.scala:76)
at scala.App.main$(App.scala:74)
at A$.main(A.scala:3)
at A.main(A.scala)
Caused by: java.lang.IllegalArgumentException: dataSource or dataSourceClassName or jdbcUrl is required.
at com.zaxxer.hikari.HikariConfig.validate(HikariConfig.java:1004)
at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:77)
at io.getquill.JdbcContextConfig.dataSource(JdbcContextConfig.scala:22)
... 16 more
那么如何修复呢?我想这个程序找不到配置了。谢谢!
暂无答案!
目前还没有任何答案,快来回答吧!