javadba javadba - 3 months ago 22
Scala Question

How to change jetty port for Scalatra

I see in numerous places phrases like:


Changing the port in development Add


port in container.Configuration := 8081



to project/build.scala


But where in build.scala? Here is the vanilla build.scala. It is unclear where that addition should go:

object KeywordsBuild extends Build {
val Organization = "com.blazedb"
..
lazy val project = Project (
"keywords",
file("."),
settings = ScalatraPlugin.scalatraSettings ++ scalateSettings ++ Seq(
organization := Organization,
name := Name,
version := Version,
..
libraryDependencies ++= Seq(
"org.scalatra" %% "scalatra" % ScalatraVersion,
..
"javax.servlet" % "javax.servlet-api" % "3.1.0" % "provided"
),
scalateTemplateConfig in Compile <<= (sourceDirectory in Compile){ base =>
Seq(
TemplateConfig(
base / "webapp" / "WEB-INF" / "templates",
Seq.empty, /* default imports should be added here */
Seq(
Binding("context", "_root_.org.scalatra.scalate.ScalatraRenderContext", importMembers = true, isImplicit = true)
), /* add extra bindings here */
Some("templates")
)


Wherever I have tried to put it the following error message happens:

[info] Compiling 1 Scala source to /shared/wfdemo/project/target/scala-2.10/sbt-0.13/classes...
/shared/wfdemo/build.sbt:1: error: not found: value port
port in container.Configuration := 8081

Answer

The correct way is to add to

build.sbt

So the documentation appears to be incorrect - or at the least misleading.

$cat build.sbt
val myPort = 9090

jetty(port = myPort)
Comments