简体   繁体   English

可以在没有激活器(和maven)的情况下使用Play 2.3.x吗?

[英]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 . 在Play 2.2.x中,发行版被捆绑为zip文件,可通过maven存储库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. 这意味着您可以使用pom.xml并将游戏嵌入到您的应用中,而无需使用sbt。 Given 2.3.x has shifted to the activator model, is it still possible to use it with maven? 鉴于2.3.x已转向激活模型,是否仍可以将其与maven一起使用?

And secondly, is it possible to use play 2.3.x without activator at all? 其次,是否可以使用没有激活器的游戏2.3.x? (I know they have a sbt plugin for play, but that seems very complex as well). (我知道他们有一个sbt插件可以玩,但这看起来也很复杂)。

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). 在创建空项目之后,您只需要sbt(实际上它是激活器的一个非常重要的部分)。

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. 使用游戏2.3,分发模型从一个大的zip文件变为常规的常春藤/ maven依赖项,因此您可以从maven项目中获得所有依赖项。 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. 问题是sbt play设置做得更多:模板编译,路由DSL编译,热重新加载,资产管道的东西,所以我不认为maven实际上是一个选项。

Yes. 是。

Example on Github 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

  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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