如何在Play框架2.5.4中配置maven?

时间:2016-06-23 06:35:44

标签: java maven playframework-2.5

我想用maven配置配置我的项目播放框架2.5.4 同时我想使用maven生成war文件, 所以我想要帮助配置。

我在plugin.sbt中添加了插件

addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "2.5.4")

和bulid.sbt

Play2WarPlugin.play2WarSettings
Play2WarKeys.servletVersion := "3.1"

在编译我的项目时,它显示了像

这样的问题
[warn]  module not found: com.github.play2war#play2-war-plugin;2.5.4
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/com.github.play2war/play2-war-plugin/scala_2.10/sbt_0.13/2.5.4/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/com.github.play2war/play2-war-plugin/scala_2.10/sbt_0.13/2.5.4/ivys/ivy.xml
[warn] ==== local: tried
[warn]   C:\Users\sarathb\.ivy2\local\com.github.play2war\play2-war-plugin\scala_2.10\sbt_0.13\2.5.4\ivys\ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/com/github/play2war/play2-war-plugin_2.10_0.13/2.5.4/play2-war-plugin-2.5.4.pom
[warn] ==== activator-launcher-local: tried
[warn]   C:\activator-1.3.10-minimal\repository\com.github.play2war\play2-war-plugin\scala_2.10\sbt_0.13\2.5.4\ivys\ivy.xml
[warn] ==== activator-local: tried
[warn]   C:\activator-dist-1.3.10\repository\com.github.play2war\play2-war-plugin\scala_2.10\sbt_0.13\2.5.4\ivys\ivy.xml
[warn] ==== typesafe-releases: tried
[warn]   http://repo.typesafe.com/typesafe/releases/com/github/play2war/play2-war-plugin_2.10_0.13/2.5.4/play2-war-plugin-2.5.4.pom
[warn] ==== typesafe-ivy-releasez: tried
[warn]   http://repo.typesafe.com/typesafe/ivy-releases/com.github.play2war/play2-war-plugin/scala_2.10/sbt_0.13/2.5.4/ivys/ivy.xml
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.github.play2war#play2-war-plugin;2.5.4: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]          com.github.play2war:play2-war-plugin:2.5.4 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]          com.github.play2war:play2-war-plugin:2.5.4 (scalaVersion=2.10, sbtVersion=0.13) (C:\play\project\plugins.sbt#L24-25)
[warn]            +- default:play-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)

当我在eclipse中运行maven build时:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/play/app/controllers/UserController.java:[3,20] package javax.inject does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[5,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[7,16] package play.mvc does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[8,16] package play.mvc does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[11,37] cannot find symbol
  symbol: class Controller
[ERROR] /C:/play/app/services/MailController.java:[3,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[4,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[5,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[7,16] package play.mvc does not exist
[ERROR] /C:/play/app/services/MailController.java:[8,16] package play.mvc does not exist
[ERROR] /C:/play/app/services/MailController.java:[10,37] cannot find symbol
  symbol: class Controller
[ERROR] /C:/play/app/controllers/UserController.java:[21,16] cannot find symbol
  symbol:   class Result
  location: class controllers.UserController
[ERROR] /C:/play/app/controllers/UserController.java:[21,38] cannot find symbol
  symbol:   class EmailException
  location: class controllers.UserController
[ERROR] /C:/play/app/services/MailController.java:[13,10] cannot find symbol
  symbol:   class Result
  location: class services.MailController
[ERROR] /C:/play/app/services/MailController.java:[13,36] cannot find symbol
  symbol:   class EmailException
  location: class services.MailController
[ERROR] /C:/play/app/Filters.java:[1,1] package javax.inject does not exist
[ERROR] /C:/play/app/Filters.java:[2,1] package play does not exist
[ERROR] /C:/play/app/Filters.java:[3,16] package play.mvc does not exist
[ERROR] /C:/play/app/Filters.java:[4,17] package play.http does not exist
[ERROR] /C:/play/app/Filters.java:[5,1] package play.mvc does not exist
[ERROR] /C:/play/app/Filters.java:[7,15] cannot access filters.ExampleFilter
  bad source file: C:\play\app\filters\ExampleFilter.java
    file does not contain class filters.ExampleFilter
    Please remove or make sure it appears in the correct subdirectory of the sourcepath.
[ERROR] /C:/play/app/controllers/UserController.java:[15,10] cannot find symbol
  symbol:   class Inject
  location: class controllers.UserController
[INFO] 22 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.981 s
[INFO] Finished at: 2016-06-23T11:27:32+05:30
[INFO] Final Memory: 14M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project play: Compilation failure: Compilation failure:
[ERROR] /C:/play/app/controllers/UserController.java:[3,20] package javax.inject does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[5,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[7,16] package play.mvc does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[8,16] package play.mvc does not exist
[ERROR] /C:/play/app/controllers/UserController.java:[11,37] cannot find symbol
[ERROR] symbol: class Controller
[ERROR] /C:/play/app/services/MailController.java:[3,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[4,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[5,31] package org.apache.commons.mail does not exist
[ERROR] /C:/play/app/services/MailController.java:[7,16] package play.mvc does not exist
[ERROR] /C:/play/app/services/MailController.java:[8,16] package play.mvc does not exist
[ERROR] /C:/play/app/services/MailController.java:[10,37] cannot find symbol
[ERROR] symbol: class Controller
[ERROR] /C:/play/app/controllers/UserController.java:[21,16] cannot find symbol
[ERROR] symbol:   class Result
[ERROR] location: class controllers.UserController
[ERROR] /C:/play/app/controllers/UserController.java:[21,38] cannot find symbol
[ERROR] symbol:   class EmailException
[ERROR] location: class controllers.UserController
[ERROR] /C:/play/app/services/MailController.java:[13,10] cannot find symbol
[ERROR] symbol:   class Result
[ERROR] location: class services.MailController
[ERROR] /C:/play/app/services/MailController.java:[13,36] cannot find symbol
[ERROR] symbol:   class EmailException
[ERROR] location: class services.MailController
[ERROR] /C:/play/app/Filters.java:[1,1] package javax.inject does not exist
[ERROR] /C:/play/app/Filters.java:[2,1] package play does not exist
[ERROR] /C:/play/app/Filters.java:[3,16] package play.mvc does not exist
[ERROR] /C:/play/app/Filters.java:[4,17] package play.http does not exist
[ERROR] /C:/play/app/Filters.java:[5,1] package play.mvc does not exist
[ERROR] /C:/play/app/Filters.java:[7,15] cannot access filters.ExampleFilter
[ERROR] bad source file: C:\play\app\filters\ExampleFilter.java
[ERROR] file does not contain class filters.ExampleFilter
[ERROR] Please remove or make sure it appears in the correct subdirectory of the sourcepath.
[ERROR] /C:/play/app/controllers/UserController.java:[15,10] cannot find symbol
[ERROR] symbol:   class Inject
[ERROR] location: class controllers.UserController
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

建议我提供任何示例代码或您的想法。

2 个答案:

答案 0 :(得分:0)

由于您声明的版本不存在,因此无法解决相关性问题。正如您在project documentation play2-war-plugin中看到的那样,版本号与播放版本不同:

  

当前版本:

     

播放2.2.x:1.2.1      播放2.3.0 - > 2.3.1:1.3-beta1(Scala 2.10& 2.11)

     

播放2.3.2 +:1.3-beta3(Scala 2.10& 2.11)

     

播放2.4.x:1.4-beta1(Scala 2.10& 2.11)

     

播放2.5.x:尚不支持

如您所见,尚不支持播放2.5.x。对于Play 2.4.x,您的plugin.sbt文件看起来像

addSbtPlugin("com.github.play2war" %% "play2-war-plugin" % "1.4-beta1")

答案 1 :(得分:0)

你没有写,你如何配置你的Maven构建。

无论如何,你可以使用Maven Plugin for Play 2.x(https://github.com/play2-maven-plugin/play2-maven-plugin)。

Play的WAR项目示例! 2.4.x和Servlet API 3.1在这里:https://github.com/play2-maven-plugin/play2-maven-test-projects/tree/master/play24/war/helloworld-war-servlet-3.1 它使用play2-war-plugin发布的com.github.play2war:play2-war-core-servlet31_2.11工件。如前所述,不支持播放2.5.x(还是?)。