【转载】play framework 2.0 实战(5)- tomcat部署

play framework 2.0 暂时不支持打包成war 。对于要部署到tomcat 还是有一定麻烦的,但是在git上还是有支持打包的方法。github.com/dlecan/play2-war-plugin  本文参考了使用指南进行了一次部署。下面是相关过程,希望对大家有帮助,

1.  要增加plugin.sbt 中的支持, 因为这是一个插件

 

resolvers += "Play2war plugins release" at "http://repository-play-war.forge.cloudbees.com/release/" addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "0.7")


2. 对Build.scala 进行修改 

 

//新增头文件

 

import com.github.play2war.plugin._

 

//

 

val appVersion      = "1.0-SNAPSHOT" val projectSettings = Play2WarPlugin.play2WarSettings ++ Seq(   // Your settings   Play2WarKeys.servletVersion := "3.0" //这里可以是2.5 看你使用的容器 ) ... val main = PlayProject(    appName, appVersion, appDependencies, mainLang = JAVA ).settings(projectSettings: _*)

 

3. 添加日志 conf/logger.xml

<configuration>


    <conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />


    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">

        <encoder>

            <pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>

        </encoder>

    </appender>


    <logger name="play" level="TRACE" />

    <logger name="application" level="INFO" />


    <!-- Off these ones as they are annoying, and anyway we manage configuration ourself -->

    <logger name="com.avaje.ebean.config.PropertyMapLoader" level="OFF" />

    <logger name="com.avaje.ebeaninternal.server.core.XmlConfigLoader" level="OFF" />

    <logger name="com.avaje.ebeaninternal.server.lib.BackgroundThread" level="OFF" />


    <root level="ERROR">

        <appender-ref ref="STDOUT" />

    </root>


</configuration>

4. 编译生成war包  play package

5. 注意要把你的war包重命名放到你的tomcat webapp的根目录里。 (2.1 才支持在子目录,希望尽快发布)


你可能感兴趣的:(【转载】play framework 2.0 实战(5)- tomcat部署)