简体   繁体   中英

Can Play 2.3.x be used without Activator (and with maven)?

I have two related questions here.

In Play 2.2.x, the distribution was bundled as a zip file, and available for download through the maven repository http://downloads.typesafe.com/play/2.2.x/play-2.2.x.zip . This meant that you could use a pom.xml and embed play into your app without needing to use sbt. Given 2.3.x has shifted to the activator model, is it still possible to use it with maven?

And secondly, is it possible to use play 2.3.x without activator at all? (I know they have a sbt plugin for play, but that seems very complex as well).

Thanks!

Activator is only needed to create the empty template project, which you could also do by hand if you know a bit about play. After that empty project is created all you need is sbt (which actually is a pretty central part of activator).

With play 2.3 the distribution model changed from the one big zip-file to regular ivy/maven dependencies, so you could possibly get all dependencies right from a maven project. The problem is that the sbt play setup does so much more: template compilation, routes DSL compilation, hot reloading, asset pipeline stuff, so I don't think maven actually is an option.

Yes.

Example on Github

package io.github.alancnet

import java.io.File

import play.api.{Environment, ApplicationLoader}

object PlayTest {
  class Dummy{}
  def main(args:Array[String]):Unit = {
    def startWebServer = {
      val environment = new Environment(
        new File("."),
        classOf[Dummy].getClassLoader,
        play.api.Mode.Dev
      )
      val context = play.api.ApplicationLoader.createContext(environment)
      val application = ApplicationLoader(context).load(context)

      play.api.Play.start(application)

      play.core.server.NettyServer.fromApplication(
        application
      )
    }

    startWebServer

  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM