playframework2.2.x 打war包
阿新 • • 發佈:2019-02-06
project.sbt 加入play2war外掛
resolvers += Resolver.url( "sbt-plugin-snapshots", url("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-snapshots"))( Resolver.ivyStylePatterns) addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.2.1")
project 資料夾 新增Build.scala
import sbt._ import Keys._ importplay.Project._ import com.github.play2war.plugin._ object ApplicationBuild extends Build { val appName = "nas" val appVersion = "1.0" val appDependencies = Seq( javaCore, javaJdbc, javaEbean, "com.github.play2war.ext" %% "redirect-playlogger" % "1.0.1", "com.github.play2war.ext" %% "jboss7-reflections-vfs-integration-play2"% "1.0.0" ) val main = play.Project(appName, appVersion, appDependencies).settings( Play2WarKeys.servletVersion := "3.1", // resolvers += Resolver.file("Local Ivy Repository", file(Path.userHome.absolutePath+"/.ivy2/local"))(Resolver.ivyStylePatterns), resolvers += "snapshots" at "https://oss.sonatype.org/content/repositories/snapshots").settings(Play2WarPlugin.play2WarSettings: _*)
idea 編譯以後自動匯入外掛包
這裡
Play2WarKeys.servletVersion := "3.1"對應servlet3 3.0對應servlet25 根據自己需要修改
執行命令play war
會在target 目錄下生成war包
根目錄下回產生一個web.xml
如果沒有的話 可以複製下面的 我的web.xml 對應的是servlet31 自己可以修改
<?xml version="1.0" ?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1" metadata-complete="true"> <display-name>Play! nas</display-name> <listener> <listener-class>play.core.server.servlet31.Play2Servlet</listener-class> </listener> <servlet> <servlet-name>play</servlet-name> <servlet-class>play.core.server.servlet31.Play2Servlet</servlet-class> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>play</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>將war包放入tomcat 執行