scala - Changing Scalatra Port -


this sounds basic, cost me whole day: want change change port scalatra runs on, in development. started hello world g8 template, , have been building there.

here's i've tried far:

changing port in build.scala, ala documentation: http://www.scalatra.org/guides/deployment/configuration.html doesn't compile, because port undefined.

changing port in build.scala, ala these 2 examples: https: gist.github.com dozed 58af6cfbfe721a562a48 https://github.com/jamesearldouglas/xsbt-web-plugin/blob/master/src/sbt-test/web/servlet/project/build.scala same problem: port undefined

redefining entry point, ala http: www.scalatra.org guides deployment standalone.html still runs on port 8080

changing init params in bootstrap, ala http: www.scalatra.org guides deployment configuration.html still runs on port 8080

any appreciated. can't post more 2 links reason, replace spaces forward slashes follow urls.

here's build.scala in case helps.

import sbt._ import keys._ import org.scalatra.sbt._ import org.scalatra.sbt.pluginkeys._ import com.mojolly.scalate.scalateplugin._ import scalatekeys._ import com.earldouglas.xsbtwebplugin._ import webplugin._  object yesmanbuild extends build {   val organization = "com.prezi"   val name = "yes man"   val version = "0.1.0-snapshot"   val scalaversion = "2.10.2"   val scalatraversion = "2.2.1"    //def conf = config("container")    lazy val project = project (     "yes-man",     file("."),     settings = defaults.defaultsettings ++ scalatraplugin.scalatrawithjrebel ++ scalatesettings ++ seq(       //port in conf := 8081,       mainclass := some("com.prezi.eureka.jettylauncher.main"),       organization := organization,       name := name,       version := version,       scalaversion := scalaversion,       resolvers += classpaths.typesafereleases,       librarydependencies ++= seq(         "org.slf4j" % "slf4j-log4j12" % "1.7.5",         "com.netflix.eureka" % "eureka-client" % "1.1.97",         "com.netflix.ribbon" % "ribbon-httpclient" % "0.1.10",         "com.netflix.ribbon" % "ribbon-eureka" % "0.1.11",         "org.scalatra" %% "scalatra" % scalatraversion,         "org.scalatra" %% "scalatra-scalate" % 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")),         "org.eclipse.jetty.aggregate" % "jetty-all" % "9.0.4.v20130625"       ),       scalatetemplateconfig in compile <<= (sourcedirectory in compile){ base =>         seq(           templateconfig(             base / "webapp" / "web-inf" / "templates",             seq.empty,  /* default imports should added here */             seq(               binding("context", "_root_.org.scalatra.scalate.scalatrarendercontext", importmembers = true, isimplicit = true)             ),  /* add bindings here */             some("templates")           )         )       }     )   ) } 

thanks guys,

~erik

update 23.01.2016: scalatra-sbt uses xsbt-web-plugin 2.0.4 , few settings changed. can find xsbt-web-plugin docs here (related note: integrations xsbt-web-plugin, sbt-web, docker , standalone builds can found in https://github.com/scalatra/scalatra-in-action, see chapter09-* directories).

for scalatra app means:

  • use jetty:start, jetty:stop instead container:start, container:stop
  • enable jettyplugin
  • use new keys, e.g. containerport in jetty := 8090, target in webappprepare, sourcedirectory in webappprepare
  • only .scala based sbt build definition: use correct imports import plugin , setting keys

a .sbt build definition:

organization := "org.foo" name := "my build" version := "0.1.0-snapshot" scalaversion := "2.11.6"  val scalatraversion = "2.4.0"  librarydependencies ++= seq(   "org.scalatra" %% "scalatra" % scalatraversion,   "org.scalatra" %% "scalatra-specs2" % scalatraversion % "test",   "com.typesafe" % "config" % "1.2.1",   "ch.qos.logback" % "logback-classic" % "1.1.3" % "runtime",   "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided" )  enableplugins(jettyplugin)  containerport in jetty := 8090 

a .scala based sbt build definition have bit less magic, , need import plugin , settings:

import sbt._ import keys._  import org.scalatra.sbt._  import com.earldouglas.xwp.jettyplugin import com.earldouglas.xwp.jettyplugin.autoimport._ import com.earldouglas.xwp.containerplugin.autoimport._ 

the actual build definition enableplugins(jettyplugin) , custom port:

object mybuild extends build {   val organization = "org.foo"   val name = "my build"   val version = "0.1.0-snapshot"   val scalaversion = "2.11.6"   val scalatraversion = "2.4.0"    val mysettings =     scalatraplugin.scalatrasettings ++ seq(       organization := organization,       name := name,       version := version,       scalaversion := scalaversion,       librarydependencies ++= seq(         "org.scalatra" %% "scalatra" % scalatraversion,         "org.scalatra" %% "scalatra-specs2" % scalatraversion % "test",         "com.typesafe" % "config" % "1.2.1",         "ch.qos.logback" % "logback-classic" % "1.1.3" % "runtime",         "javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"       ),       containerport in jetty := 8090     )    lazy val project = project("chapter09", file("."))     .enableplugins(jettyplugin)     .settings(mysettings: _*)  } 

make sure using imports:

import com.earldouglas.xsbtwebplugin.pluginkeys._ import com.earldouglas.xsbtwebplugin.webplugin._ 

with imports can use correct key , configuration:

port in container.configuration := 9000 

this goes in settings block:

... lazy val project = project (   "example",   file("."),   settings = defaults.defaultsettings ++ scalatraplugin.scalatrawithjrebel ++ scalatesettings ++ seq(     port in container.configuration := 9000,     organization := organization, ... 

scalatra-sbt builds on xsbt-web-plugin settings documented here: https://github.com/jamesearldouglas/xsbt-web-plugin/wiki/settings


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -