【问题标题】:Not able to package Play framework with java project into war无法将带有 java 项目的 Play 框架打包到战争中
【发布时间】:2014-12-09 09:03:41
【问题描述】:

您好,我实际上是在尝试在 AWS EC2 实例上部署我的应用程序。为此,我在那里运行了我的 tomcat 服务器。我想从这个游戏项目中创建一个战争文件。并且在 eclipse 中没有显示错误。我的项目目录是 play-userReg :

C:\playdemo>play war play-userReg -o myapp.war
~        _            _
~  _ __ | | __ _ _  _| |
~ | '_ \| |/ _' | || |_|
~ |  __/|_|\____|\__ (_)
~ |_|            |__/
~
~ play! 1.3.x-1.3.0RC1, http://www.playframework.org
~
~ Warning: no application.mode defined in you conf/application.conf. Using DEV mode.
Listening for transport dt_socket at address: 8000
14:25:36,029 INFO  ~ Starting C:\playdemo\play-userReg
14:25:36,431 INFO  ~ Precompiling ...
14:25:37,969 ERROR ~

@6keg3pk9m
Cannot start in PROD mode with errors

Compilation error (In /app/Global.java around line 8)
The file /app/Global.java could not be compiled. Error raised is : GlobalSettings cannot be resolved to a type

play.exceptions.CompilationException: GlobalSettings cannot be resolved to a type
        at play.classloading.ApplicationCompiler$2.acceptResult(ApplicationCompiler.java:256)
        at org.eclipse.jdt.internal.compiler.Compiler.handleInternalException(Compiler.java:679)
        at org.eclipse.jdt.internal.compiler.Compiler.compile(Compiler.java:523)
        at play.classloading.ApplicationCompiler.compile(ApplicationCompiler.java:292)
        at play.classloading.ApplicationClassloader.getAllClasses(ApplicationClassloader.java:427)
        at play.Play.preCompile(Play.java:604)
        at play.Play.init(Play.java:308)
        at play.server.Server.main(Server.java:160)
~ Please fix compilation errors before packaging WAR
~

我的 build.sbt 文件是:

name := """play-userReg"""

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
    "com.typesafe.play" %% "play" % "2.3.0" % "provided",
    "org.springframework" % "spring-core" % "3.2.2.RELEASE",
    "org.springframework" % "spring-context" % "3.2.2.RELEASE",
    "org.mongodb" % "mongo-java-driver" % "2.11.0",
    "org.springframework.data" % "spring-data-mongodb" % "1.2.0.RELEASE",
    "cglib" % "cglib" % "2.2.2",
    javaCore,
    javaJdbc,
    javaEbean
)

lazy val root = (project in file(".")).enablePlugins(PlayJava)

【问题讨论】:

  • 错误清楚地表明Compilation error (In /app/Global.java around line 8) 存在问题。
  • 嗨@Jatin 回复。但正如我所见,我的日食没有错误。
  • 好吧,也许你应该告诉 sbt 在 eclipse 中一切都很好 :) 编译器是事实的来源,不要依赖有问题的 IDE 来判断你的代码是否有错误.
  • 你怎么有一个build.sbt,却有一个1.3版本的框架?
  • 我使用 activator 1.2.10 创建了我的项目

标签: java scala amazon-web-services amazon-ec2 playframework


【解决方案1】:

您似乎正在尝试使用 Play 1 构建 Play 2 项目。

你应该运行“activator”而不是“play”。

【讨论】:

  • 当我说激活器运行时,我的应用程序运行良好。但是如果我试图将它打包成一个战争,那么我会得到这个错误
  • 但是你仍然应该使用“activator war”而不是“play war”,因为“play”指的是Play1,“activator”指的是Play2。
猜你喜欢
  • 2014-11-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-12
  • 1970-01-01
  • 2017-12-22
  • 1970-01-01
  • 2015-11-18
相关资源
最近更新 更多