是否有可用于从 Play 框架项目生成战争的插件?
c:\>myproject>play war
上面提到的命令会生成战争,但是当部署在 Weblogic 或 Websphere 上时,它不会被部署。过去尝试过,但未能成功部署。
是否有可用于从 Play 框架项目生成战争的插件?
c:\>myproject>play war
上面提到的命令会生成战争,但是当部署在 Weblogic 或 Websphere 上时,它不会被部署。过去尝试过,但未能成功部署。
如果您的项目基于 play framework 2.x,这个插件过去对我有用: https ://github.com/dlecan/play2-war-plugin
已在 play 版本 2.1.1 中成功使用它。
参考:https ://github.com/dlecan/play2-war-plugin
修改了两个文件以获得相同的工作 / 以将 Play 应用程序部署为 WAR。
1) under "/playframeworkProject/project/plugins.sbt" add the following at the bottom
// Added for WAR deployment support
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.2-beta1")
2) under "/playframeworkProject/project/Build.scala"
import com.github.play2war.plugin._
Make following code changes.
object ApplicationBuild extends Build {
.
.
.
lazy val main = play.Project(appName, appVersion, appDependencies)
.settings(Play2WarPlugin.play2WarSettings: _*)
.
.
resourceDirectory in IntegrationTest <<= baseDirectory /"it/resources",
Play2WarKeys.servletVersion := "3.0")
.
.
}
最终应该看起来像 >>>
object ApplicationBuild extends Build {
import com.mckesson.builder.Resolvers._
val appName = "YourPlayProjectName"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = com.companyname.builder.Dependencies.YourPlayProjectName
resolvers := com.companyname.builder.Resolvers.XYZResolvers
lazy val main = play.Project(appName, appVersion, appDependencies)
.settings(Play2WarPlugin.play2WarSettings: _*)
.settings( playCommonSettings: _*
).configs( IntegrationTest ).settings( Defaults.itSettings :_*)
.settings(scalaSource in IntegrationTest <<= baseDirectory /"it" ,
scalaSource in Test <<= baseDirectory /"test",
resourceDirectory in IntegrationTest <<= baseDirectory /"it/resources",
Play2WarKeys.servletVersion := "3.0")
}
通过 sbt clean publish-local cd 重新构建项目到 YourPlayProjectName 目录运行 play war 或 sbt war 以生成 WAR
转到 YourPlayProjectName/target/ 找到 WAR
将 WAR 重命名为 ROOT.war
将它复制到 Tomcat 7 的 webapps 文件夹中
请注意,您需要定义 CATALINA_HOME 环境变量并将其 /bin 添加到您的路径
示例:C:>echo %CATALINA_HOME% C:\apache\apache-tomcat-7.0.40 4. 启动数据库
5. Start Tomcat 7 with this command from your command prompt (no specific location as long as your CATILANA_HOME is set correctly in your environment variable) catalina start
6. Start your other dependencies if any to make sure your application works.
在浏览器中,点击 http://:8080 以查看您的应用程序正在运行并成功部署。
享受!!
这个页面肯定会帮助您了解生成战争文件所需的配置... https://github.com/play2war/play2-war-plugin/wiki/Configuration
通常您必须在添加配置的地方进行更改:
1. plugins.sbt(project-root/project/)
2.build.sbt (project-root)
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.4-beta1")
构建.sbt
import com.github.play2war.plugin._
libraryDependencies ++= Seq(
"com.github.play2war" % "play2-war_2.9.1" % "0.8.2" # Change version
)
Play2WarPlugin.play2WarSettings
Play2WarKeys.servletVersion := "2.5" # Change as per your requirement(3.0 or 3.1 etc)
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.4-beta1")
运行 [sbt 战争]