I have been trying to get slick's schema code generation to work. This is the method I'm using to run slicks code generator and the result that I'm getting.
scala>slick.codegen.SourceCodeGenerator.main(Array("slick.driver.MySQLDriver","com.mysql.jdbc.Driver","jdbc:mysql://localhost/adivinate","/Users/roy/adivinate/survey2/app/database","database","root","root"))
java.lang.NoSuchMethodError: slick.driver.JdbcProfile$API.Database()Lslick/backend/DatabaseComponent$DatabaseFactoryDef;
at slick.codegen.SourceCodeGenerator$.run(SourceCodeGenerator.scala:65)
at slick.codegen.SourceCodeGenerator$.main(SourceCodeGenerator.scala:94)
... 42 elided
scala>
I think I am missing a dependency but I don't know how to find it.
Here is my build.sbt.
name := """adivinate"""
version := "0.0.1"
lazy val root = (project in file(".")).enablePlugins(PlayScala)
scalaVersion := "2.11.8"
incOptions := incOptions.value.withNameHashing(true)
updateOptions := updateOptions.value.withCachedResolution(cachedResoluton = true)
libraryDependencies ++= {
val ngVersion="2.2.0"
Seq(
cache,
evolutions,
//angular2 dependencies
"org.webjars.npm" % "angular__common" % ngVersion,
"org.webjars.npm" % "angular__compiler" % ngVersion,
"org.webjars.npm" % "angular__core" % ngVersion,
"org.webjars.npm" % "angular__http" % ngVersion,
"org.webjars.npm" % "angular__forms" % ngVersion,
"org.webjars.npm" % "angular__router" % "3.2.0",
"org.webjars.npm" % "angular__platform-browser-dynamic" % ngVersion,
"org.webjars.npm" % "angular__platform-browser" % ngVersion,
"org.webjars.npm" % "systemjs" % "0.19.40",
"org.webjars.npm" % "rxjs" % "5.0.0-beta.12",
"org.webjars.npm" % "reflect-metadata" % "0.1.8",
"org.webjars.npm" % "zone.js" % "0.6.26",
"org.webjars.npm" % "core-js" % "2.4.1",
"org.webjars.npm" % "symbol-observable" % "1.0.1",
"org.webjars.npm" % "typescript" % "2.1.4",
//tslint dependency
"org.webjars.npm" % "tslint-eslint-rules" % "3.1.0",
"org.webjars.npm" % "tslint-microsoft-contrib" % "2.0.12",
// "org.webjars.npm" % "codelyzer" % "2.0.0-beta.1",
"org.webjars.npm" % "types__jasmine" % "2.2.26-alpha" % "test",
//test
// "org.webjars.npm" % "jasmine-core" % "2.4.1"
//database dependencies
"mysql" % "mysql-connector-java" % "5.1.30",
//"com.typesafe.slick" % "slick_2.11" % "3.1.1", //included in play-slick
"com.typesafe.play" %% "play-slick" % "2.0.0",
"com.typesafe.play" %% "play-slick-evolutions" % "2.0.0",
"com.typesafe.slick" %% "slick-codegen" % "3.0.0",
"org.scala-lang" % "scala-reflect" % "2.12.1"
)
}
dependencyOverrides += "org.webjars.npm" % "minimatch" % "3.0.0"
// use the webjars npm directory (target/web/node_modules ) for resolution of module imports of angular2/core etc
resolveFromWebjarsNodeModulesDir := true
// use the combined tslint and eslint rules plus ng2 lint rules
(rulesDirectories in tslint) := Some(List(
tslintEslintRulesDir.value,
ng2LintRulesDir.value
))
logLevel in tslint := Level.Debug
routesGenerator := InjectedRoutesGenerator
fork in run := true
Related
I'm trying to build a Scala project based on the framework Play using the sbt. When I try to launch "sbt compile" from my terminal I get several compilation errors like the following one:
[error] <project.dir>/app/controllers/Application.scala:229:
object database is not a member of package views.html
[error] Ok(views.html.database(t2, JsonHelpers.TotalTip.langsForm))
[error] ^
This is my build.sbt file:
import play.sbt.PlayImport._
import com.typesafe.sbt.less.Import.LessKeys
name := """<app_name>"""
lazy val root = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(GatlingPlugin)
.enablePlugins(BuildInfoPlugin, GitVersioning, GitBranchPrompt)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "app")
https://github.com/puffnfresh/wartremover/issues/182
wartremoverWarnings ++= Warts.unsafe.filter(_ != Wart.Throw)
git.useGitDescribe := true
routesGenerator := InjectedRoutesGenerator
fork in run := true
scalaVersion := "2.11.8"
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.5.4"
libraryDependencies ++= Seq(
jdbc,
cache,
ws,
filters,
specs2 % Test,
"com.typesafe.play" % "anorm_2.11" % "2.5.0",
"org.webjars" % "bootstrap" % "3.3.2",
"org.webjars" % "metisMenu" % "1.1.3",
"org.webjars" % "morrisjs" % "0.5.1",
"org.webjars" % "font-awesome" % "4.3.0",
"org.webjars" % "jquery" % "2.1.3",
"org.webjars" % "flot" % "0.8.3",
"org.webjars" % "datatables" % "1.10.5",
"org.webjars" % "datatables-plugins" % "1.10.5",
"com.newrelic.agent.java" % "newrelic-agent" % "3.14.0",
"com.newrelic.agent.java" % "newrelic-api" % "3.14.0",
"org.pac4j" % "play-pac4j" % "2.6.2",
"org.pac4j" % "pac4j-saml" % "1.9.5",
"org.pac4j" % "pac4j-sql" % "1.9.5",
"org.pac4j" % "pac4j-oidc" % "1.9.5" exclude("commons-io" , "commons-io"),
"org.pac4j" % "pac4j-openid" % "1.9.5" exclude("xml-apis" , "xml-apis"),
"org.pac4j" % "pac4j-jwt" % "1.9.5" exclude("commons-io" , "commons-io"),
"org.pac4j" % "pac4j-mongo" % "1.9.5",
"org.pac4j" % "pac4j-http" % "1.9.5",
"org.pac4j" % "pac4j-oauth" % "1.9.5",
"org.pac4j" % "pac4j-stormpath" % "1.9.5",
"com.typesafe.play" % "play-cache_2.11" % "2.5.4",
"org.pac4j" % "pac4j-http" % "1.9.5",
"org.pac4j" % "pac4j-cas" % "1.9.5",
"commons-io" % "commons-io" % "2.5"
)
includeFilter in (Assets, LessKeys.less) := "sb-admin-2.less" | "tables.less"
libraryDependencies += "io.gatling.highcharts" % "gatling-charts-highcharts" % "2.1.7"
libraryDependencies += "io.gatling" % "gatling-test-framework" % "2.1.7"
libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.5"
libraryDependencies += "org.reactivemongo" %% "reactivemongo" % "0.11.10"
libraryDependencies += "io.swagger" %% "swagger-play2" % "1.6.0"
libraryDependencies += "com.github.tototoshi" %% "play-json-naming" % "1.0.0"
libraryDependencies += "com.github.tototoshi" %% "scala-csv" % "1.3.4"
libraryDependencies += "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.8.7"
libraryDependencies += "com.github.nscala-time" %% "nscala-time" % "2.16.0"
resolvers ++= Seq(Resolver.mavenLocal, "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases", "Sonatype snapshots repository" at "https://oss.sonatype.org/content/repositories/snapshots/", "<internal repo>" at "<repo_url>")
Is it a dependencies issue? Does anyone have an idea why I get these errors?
Thanks
sbt clean compile
sometime that helps
if not have a look at https://www.playframework.com/documentation/2.5.x/IDE
I've imported Specs2 and everything looks good but some things that are not imported, among them the PlaySpecification trait.
I've tried to reload in sbt, to invalidate caches in Intellij ... But this trait is missing!
My built.sbt
name := """web2"""
version := "1.0-SNAPSHOT"
scalaVersion := "2.12.2"
lazy val root = (project in file(".")).enablePlugins(PlayScala, LauncherJarPlugin)
pipelineStages := Seq(digest)
libraryDependencies ++= Seq(
evolutions,
jdbc,
ehcache,
ws,
"com.softwaremill.macwire" %% "macros" % "2.3.0" % "provided",
"org.postgresql" % "postgresql" % "42.1.1",
"org.scalikejdbc" %% "scalikejdbc" % "3.0.0",
"org.scalikejdbc" %% "scalikejdbc-config" % "3.0.0",
"ch.qos.logback" % "logback-classic" % "1.2.3",
"de.svenkubiak" % "jBCrypt" % "0.4.1",
//"org.scalatestplus.play" %% "scalatestplus-play" % "3.0.+" % "test",
"org.mockito" % "mockito-core" % "2.7.22" % "test",
"org.specs2" %% "specs2-core" % "3.9.+" % "test"
)
resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"
plugins.sbt
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.6.3")
// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.2")
According to the documentation, replace "org.specs2" %% "specs2-core" % "3.9.+" % "test" with specs2 % Test in your dependencies:
libraryDependencies ++= Seq(
evolutions,
jdbc,
ehcache,
...
"org.mockito" % "mockito-core" % "2.7.22" % "test",
specs2 % Test
)
I have a project tree consisting of three projects A, B and C
B depends on A, and C depends on both A and B.
A and B are checked out in C's lib/ and both build fine using sbt compile
However, when I compile C, the build of B fails, complaining that it cannot find certain types/packages:
import org.scalatra.sbt._
import sbt.Keys._
import sbt._
object NwbApiBuild extends Build {
val Organization = "org.nwb"
val Name = "NWB API"
val Version = "0.1.0-SNAPSHOT"
val ScalaVersion = "2.10.3"
val ScalatraVersion = "2.3.0"
lazy val active_slick= Project (
"active-slick",
base = file("lib/active-slick")
)
lazy val slick_auth= Project (
"slick-auth",
base = file("lib/slick-auth")
)
lazy val project = Project (
"root",
file("."),
settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraWithJRebel ++ Seq(
organization := Organization,
name := Name,
version := Version,
scalaVersion := ScalaVersion,
resolvers += Classpaths.typesafeReleases,
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),
"com.typesafe.slick" %% "slick" % "2.0.2",
"mysql" % "mysql-connector-java" % "5.1.31",
"joda-time" % "joda-time" % "2.3",
"org.joda" % "joda-convert" % "1.5",
"com.github.tototoshi" %% "slick-joda-mapper" % "1.1.0",
"org.json4s" %% "json4s-native" % "3.2.10",
"org.json4s" %% "json4s-jackson" % "3.2.7",
"c3p0" % "c3p0" % "0.9.1.2"
)
)
) aggregate(active_slick, slick_auth) dependsOn(active_slick, slick_auth)
}
where slick auth has build file
import org.scalatra.sbt._
name := "slick-auth"
version := "0.0.1-SNAPSHOT"
scalaVersion := "2.10.3"
val ScalatraVersion = "2.3.0"
lazy val active_slick = Project(
"active-slick",
base = file("lib/active-slick")
)
lazy val root = Project(
"root",
file("."),
settings = Defaults.defaultSettings ++ ScalatraPlugin.scalatraSettings ++ Seq(
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "2.0.2",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"org.scalatest" %% "scalatest" % "2.2.0" % "test",
"org.scalatra" %% "scalatra" % ScalatraVersion,
"org.scalatra" %% "scalatra-specs2" % ScalatraVersion % "test",
"ch.qos.logback" % "logback-classic" % "1.0.6" % "runtime",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.8.v20121106" % "container",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar")),
"com.typesafe.slick" %% "slick" % "2.0.2",
"joda-time" % "joda-time" % "2.3",
"org.joda" % "joda-convert" % "1.5",
"com.github.tototoshi" %% "slick-joda-mapper" % "1.1.0",
"org.json4s" %% "json4s-native" % "3.2.10",
"org.json4s" %% "json4s-jackson" % "3.2.7",
"c3p0" % "c3p0" % "0.9.1.2"
)
)
).aggregate(active_slick).dependsOn(active_slick)
and active_slick:
name := "active-slick"
version := "0.0.1-SNAPSHOT"
scalaVersion := "2.10.3"
libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "2.0.2",
"org.slf4j" % "slf4j-nop" % "1.6.4",
"org.scalatest" %% "scalatest" % "2.2.0" % "test",
"com.h2database" % "h2" % "1.3.166" % "test"
)
If you want to use another project as a dependency (rather than its binary version) you can use project references. There are two types of references, ProjectRef or a simpler version of the ProjectRef, which is RootProject.
You should change your build definition to reference slick_auth as
lazy val slick_auth = RootProject(file("lib/slick-auth"))
and active_slick as
lazy val active_slick = RootProject(file("lib/active-slick"))
I receive the following error when running sbt gen-idea:
[error] {file:/home/jem/projects/app/}default-0df603/*:
update-classifiers: Version specified for dependency
org.scala-lang#scalap;2.10.0 differs from Scala version in project (2.10.1).
Despite this the idea files are still created and seem to work. But I worry that they may be incomplete somehow.
Here is my build.sbt:
import com.typesafe.startscript.StartScriptPlugin
organization := "com.github.synesso"
name := "app"
version := "0.1"
scalaVersion := "2.10.1"
seq(webSettings :_*)
classpathTypes ~= (_ + "orbit")
libraryDependencies ++= Seq(
"org.scalatra" % "scalatra_2.10" % "2.2.1",
"org.scalatra" % "scalatra-scalate_2.10" % "2.2.1",
"org.scalatra" % "scalatra-json_2.10" % "2.2.1",
"org.eclipse.jetty" % "jetty-server" % "9.0.1.v20130408",
"org.eclipse.jetty" % "jetty-server" % "9.0.1.v20130408" % "container",
"org.eclipse.jetty" % "jetty-webapp" % "9.0.1.v20130408",
"org.eclipse.jetty" % "jetty-webapp" % "9.0.1.v20130408" % "container",
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container,compile",
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container,compile" artifacts Artifact("javax.servlet", "jar", "jar"),
"org.json4s" % "json4s-jackson_2.10" % "3.2.4",
"org.slf4j" % "slf4j-simple" % "1.7.5",
"ch.qos.logback" % "logback-classic" % "1.0.11" % "runtime",
"com.google.api-client" % "google-api-client" % "1.14.1-beta",
"com.google.apis" % "google-api-services-plus" % "v1-rev62-1.14.1-beta",
"com.google.apis" % "google-api-services-oauth2" % "v1-rev33-1.14.1-beta",
"com.google.http-client" % "google-http-client-jackson2" % "1.14.1-beta"
)
resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/releases/"
seq(StartScriptPlugin.startScriptForClassesSettings: _*)
I've tried mucking around with different versions of scala and the dependencies, but to no avail. What is going on here? Do I need to fix it? If so, how?
This is controlled by the checkExplicit value of the ivyScala setting. You can disable it with:
ivyScala ~= { (is: Option[IvyScala]) =>
for(i <- is) yield
i.copy(checkExplicit = false)
}
I'm surprised that is an error, since I'd normally expect it to be a warning. Also, this check is no longer on by default in 0.13.
I'm getting the following error when I try to extend SalatDAO or use grater[T].asObject(x):
class file needed by SalatDAO is missing. reference type MongoCollection of
com.mongodb.casbah.TypeImports refers to nonexisting symbol.
I've followed the Salat examples but, for some reason, extending SalatDAO and graters asObject do not work for me. I cannot find any reference to this error online.
Here's my code:
import net.trevor.model.DBConnection._
import com.novus.salat._
import com.novus.salat.global._
import com.mongodb.casbah.Imports._
import com.novus.salat.dao.SalatDAO
//error occurs on following line:
object HandleDAO extends SalatDAO[Handle, ObjectId](DBConnection.db("Handles")){
def getHandleAsDBObject(handle : Handle) : DBObject =
grater[Handle].asDBObject(handle)
def getHandleFromDBObject(dbObject : DBObject) : Handle =
//error occurs on following line:
grater[Handle].asObject(dbObject)
}
I'd really appreciate any help or advice on this. I'm new to Scala and Mongodb.
I'm compiling using sbt compile. Here's my build.sbt
name := "handle_engine"
version := "1.0"
scalaVersion := "2.9.1"
scalacOptions += "-deprecation"
fork in run := true
resolvers ++= Seq(
"twitter-repo" at "http://maven.twttr.com",
"repo.novus rels" at "http://repo.novus.com/releases/",
"repo.novus snaps" at "http://repo.novus.com/snapshots/",
"Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
)
libraryDependencies ++= {
val liftVersion = "2.4-M5" // Put the current/latest lift version here
Seq(
"net.liftweb" %% "lift-webkit" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mapper" % liftVersion % "compile->default",
"net.liftweb" %% "lift-amqp" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mongodb" % liftVersion % "compile->default",
"net.liftweb" %% "lift-mongodb-record" % liftVersion % "compile->default",
"net.liftweb" %% "lift-wizard" % liftVersion % "compile->default")
}
libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-server" % "8.1.0.RC5", // % "compile,jetty",
"org.eclipse.jetty" % "jetty-servlet" % "8.1.0.RC5", // % "compile,jetty",
"org.mongodb" % "mongo-java-driver" % "compile->default",
"com.rabbitmq" % "amqp-client" % "compile->default",
"org.mongodb" % "casbah_2.9.0-1" % "3.0.0-M2",
"com.novus" % "salat-core_2.8.1" % "0.0.7", //Salat for MongoDB and Casbah
"org.apache.avro" % "avro" % "1.6.2",
"com.twitter" % "util-core_2.9.1" % "1.12.8", "com.twitter" % "util-eval_2.9.1" % "1.12.8",
"junit" % "junit" % "4.5" % "test->default",
"javax.servlet" % "servlet-api" % "2.5" % "provided->default",
"ch.qos.logback" % "logback-classic" % "0.9.26" % "compile->default"
)
seq(webSettings :_*)
libraryDependencies += "org.mortbay.jetty" % "jetty" % "6.1.26" % "test,container"
libraryDependencies += "org.scala-tools.testing" %% "specs" % "1.6.9" % "test"
It looks like you might be on an older version of Salat. Try changing you version to following:
"com.novus" %% "salat-core" % "0.0.8-SNAPSHOT"
or
"com.novus" % "salat-core_2.9.1" % "0.0.8-SNAPSHOT"