播放后的编译错误!框架NewApplication指南

时间:2015-08-01 07:49:52

标签: java scala playframework sbt fedora

我使用Fedora 22操作系统,我试图开始使用Play!框架。当然,我试图建立最简单的应用程序,所以我可以有一个起点。

我试图尽可能地遵循文档(https://www.playframework.com/documentation/2.4.x/NewApplication)中的指南,但我在这里没有成功。当我在项目的基础文件夹中调用激活器并指示我一些未解决的依赖项时,它会失败。我将发布我已经采取的步骤,以便尽可能清楚地展示我已完成的工作和问题,包括有关Java的一些信息(我读过某些地方我应该使用Oracle Java而不是OpenJDK ,所以我下载了最新的Java SE JDK 7)和sbt,我认为这与该过程有关。 我的操作系统是葡萄牙语,因此有几行将是葡萄牙语,但由于它们涉及众所周知的命令(基本上是命令选择),我认为它不会损害理解。

su -

[root@localhost ~]# alternatives --config java

Há 3 programas que oferecem "java".

  Seleção    Comando
-----------------------------------------------
*+ 1           /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.45-36.b13.fc22.x86_64/jre/bin/java
   2           /usr/java/jdk1.7.0_79/bin/java
   3           /usr/java/default/jre/bin/java

Indique para manter a seleção atual[+] ou digite o número da seleção: 2

[root@localhost ~]# alternatives --config javac

Há 1 programa que oferece "javac".

  Seleção    Comando
-----------------------------------------------
*+ 1           /usr/java/default/bin/javac


[root@localhost ~]# alternatives --config javaws

Há 1 programa que oferece "javaws".

  Seleção    Comando
-----------------------------------------------
*+ 1           /usr/java/default/jre/bin/javaws

Indique para manter a seleção atual[+] ou digite o número da seleção: 1  

[root@localhost ~]# alternatives --config jar

Há 1 programa que oferece "jar".

  Seleção    Comando
-----------------------------------------------
*+ 1           /usr/java/default/bin/jar

Indique para manter a seleção atual[+] ou digite o número da seleção: 1

[root@localhost ~]# exit
logout

[gscofano@localhost new-project]$ java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

[gscofano@localhost new-project]$ javac -version
javac 1.7.0_79


[gscofano@localhost new-project]$ pwd 
/home/gscofano/Documentos/Programacao/play/play-2.4.2


[gscofano@localhost new-project]$ ls
activator-1.3.5-minimal


[gscofano@localhost new-project]$ mkdir new-project


[gscofano@localhost new-project]$ cd ./new-project


[gscofano@localhost new-project]$ sbt about

[info] Set current project to new-project (in build file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/)
[info] This is sbt 0.13.1
[info] The current project is {file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/}new-project 0.1-SNAPSHOT
[info] The current project is built against Scala 2.10.4
[info] 
[info] sbt, sbt plugins, and build definitions are using Scala 2.10.4


[gscofano@localhost new-project]$ ../activator-1.3.5-minimal/activator new first-app play-java

OK, application "first-app" is being created using the "play-java" template.

To run "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator run

To run the test for "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator test

To run the Activator UI for "first-app" from the command line, "cd first-app" then:
/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/activator ui


[gscofano@localhost new-project]$ cd ./first-app


[gscofano@localhost first-app]$ ./activator
[info] Loading project definition from /home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/project
[info] Updating {file:/home/gscofano/Documentos/Programacao/play/play-2.4.2/new-project/first-app/project/}first-app-build...
[info] Resolving org.scala-sbt#precompiled-2_9_3;0.13.8 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
[warn]  :: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang:scala-library:2.10.4 ((sbt.Classpaths) Defaults.scala#L1203)
[warn]        +- org.scala-sbt:control:0.13.8
[warn]        +- org.scala-sbt:io:0.13.8
[warn]        +- org.scala-sbt:classpath:0.13.8
[warn]        +- org.scala-sbt:incremental-compiler:0.13.8
[warn]        +- org.scala-sbt:persist:0.13.8
[warn]        +- org.scala-sbt:compiler-integration:0.13.8
[warn]        +- org.scala-sbt:actions:0.13.8
[warn]        +- org.scala-sbt:main:0.13.8
[warn]        +- org.scala-sbt:sbt:0.13.8
[warn]        +- default:first-app-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
[warn]      org.scala-lang:scala-compiler:2.10.4
[warn]        +- org.scala-sbt:classpath:0.13.8
[warn]        +- org.scala-sbt:incremental-compiler:0.13.8
[warn]        +- org.scala-sbt:persist:0.13.8
[warn]        +- org.scala-sbt:compiler-integration:0.13.8
[warn]        +- org.scala-sbt:actions:0.13.8
[warn]        +- org.scala-sbt:main:0.13.8
[warn]        +- org.scala-sbt:sbt:0.13.8
[warn]        +- default:first-app-build:0.1-SNAPSHOT (sbtVersion=0.13, scalaVersion=2.10)
sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
unresolved dependency: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
    at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:291)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:188)
    at sbt.IvyActions$$anonfun$updateEither$1.apply(IvyActions.scala:165)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
    at sbt.IvySbt$Module$$anonfun$withModule$1.apply(Ivy.scala:155)
    at sbt.IvySbt$$anonfun$withIvy$1.apply(Ivy.scala:132)
    at sbt.IvySbt.sbt$IvySbt$$action$1(Ivy.scala:57)
    at sbt.IvySbt$$anon$4.call(Ivy.scala:65)
    at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:93)
    at xsbt.boot.Locks$GlobalLock.xsbt$boot$Locks$GlobalLock$$withChannelRetries$1(Locks.scala:78)
    at xsbt.boot.Locks$GlobalLock$$anonfun$withFileLock$1.apply(Locks.scala:97)
    at xsbt.boot.Using$.withResource(Using.scala:10)
    at xsbt.boot.Using$.apply(Using.scala:9)
    at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:58)
    at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:48)
    at xsbt.boot.Locks$.apply0(Locks.scala:31)
    at xsbt.boot.Locks$.apply(Locks.scala:28)
    at sbt.IvySbt.withDefaultLogger(Ivy.scala:65)
    at sbt.IvySbt.withIvy(Ivy.scala:127)
    at sbt.IvySbt.withIvy(Ivy.scala:124)
    at sbt.IvySbt$Module.withModule(Ivy.scala:155)
    at sbt.IvyActions$.updateEither(IvyActions.scala:165)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1369)
    at sbt.Classpaths$$anonfun$sbt$Classpaths$$work$1$1.apply(Defaults.scala:1365)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1399)
    at sbt.Classpaths$$anonfun$doWork$1$1$$anonfun$87.apply(Defaults.scala:1397)
    at sbt.Tracked$$anonfun$lastOutput$1.apply(Tracked.scala:37)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1402)
    at sbt.Classpaths$$anonfun$doWork$1$1.apply(Defaults.scala:1396)
    at sbt.Tracked$$anonfun$inputChanged$1.apply(Tracked.scala:60)
    at sbt.Classpaths$.cachedUpdate(Defaults.scala:1419)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1348)
    at sbt.Classpaths$$anonfun$updateTask$1.apply(Defaults.scala:1310)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:40)
    at sbt.std.Transform$$anon$4.work(System.scala:63)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:226)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:17)
    at sbt.Execute.work(Execute.scala:235)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:226)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:159)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:28)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
[error] (*:update) sbt.ResolveException: unresolved dependency: org.scala-lang#scala-library;2.10.4: configuration not found in org.scala-lang#scala-library;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe#npm_2.10;1.1.1 compile
[error] unresolved dependency: org.scala-lang#scala-compiler;2.10.4: configuration not found in org.scala-lang#scala-compiler;2.10.4: 'master(compile)'. Missing configuration: 'compile'. It was required from com.typesafe.play#twirl-compiler_2.10;1.1.1 compile
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

这是build.sbt

name := """first-app"""

version := "1.0-SNAPSHOT"

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

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
  javaJdbc,
  cache,
  javaWs
)

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator

构建属性

#Activator-generated Properties
#Sat Aug 01 03:30:20 BRT 2015
template.uuid=4908845b-9453-410b-af0f-404c1440dff1
sbt.version=0.13.8

和plugins.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.2")

// Web plugins
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")

// Play enhancer - this automatically generates getters/setters for public fields
// and rewrites accessors of these fields to use the getters/setters. Remove this
// plugin if you prefer not to have this feature, or disable on a per project
// basis using disablePlugins(PlayEnhancer) in your build.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0")

// Play Ebean support, to enable, uncomment this line, and enable in your build.sbt using
// enablePlugins(SbtEbean). Note, uncommenting this line will automatically bring in
// Play enhancer, regardless of whether the line above is commented out or not.
// addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "1.0.0")

我尝试用空行分隔最后一个文件中的行。什么都没有改变。

我试图谷歌这个,但我找不到类似的东西。如果有人可以帮我解决这个问题,我会非常感激。最后,我要感谢所有花时间阅读这个问题的读者。

编辑:我刚刚意识到我正在使用/ usr / default / jre / bin / javac。当我尝试使用Java SDK 8时,我将其修复为/usr/jdk1.8.0_51/jre/bin/javac。

4 个答案:

答案 0 :(得分:2)

最后,我已经找到了解决方案。那是一件很难的事。

所以,问题是由于某种原因,sbt无法自行下载的几个依赖项。为了解决这个问题,我设置了一个常春藤构建文件并使用ant来下载它们,而不使用play,sbt或与之相关的任何东西。我将在帖子的最后发布更多详细信息。

我使用了激活器用户界面(/play-2.4.2/activator-dist-1.3.5/activator ui),它又开始构建项目。它经历了有问题的一点,稍后失败了。更多无法下载的依赖项。我使用相同的方法下载它们。它适用于所有依赖项,但其中一个是com.typesafe.sbtrc#actor-client-2-10; 0.3.1。 Ivy在maven存储库中查找我使用ant下载的依赖项,最后一个是在bintray存储库中,默认情况下至少不使用常春藤。我在我的网络浏览器中访问了这个存储库(http://dl.bintray.com/typesafe/ivy-releases/com.typesafe.sbtrc/),下载了里面的模块并放入〜/ ivy / local / com.typesafe.sbtrc /.

我再次调用了激活器用户界面,最终可以构建并运行我的项目。

稍微解释一下情况,对于那些与actor-client-2-10依赖关系有问题的人,当激活器构建项目时,它会查看maven存储库和本地存储库,但不会查看bintray存储库!我所做的只是将在bintray中找到的模块复制到我的本地存储库。当激活器查看〜/ .ivy2 / local时,它找到了它想要的工件并将其安装在〜/ .ivy2 / cache中。

如果您也采取同样措施来解决此问题,请记住创建一些目录,以便目录树在bintray存储库和本地存储库中相同。

好吧,正如所承诺的,我会发布用于下载有问题的依赖项的常春藤构建文件。首先,我们必须下载并安装ant。然后,我们转到任何目录并创建一个名为build.xml的文件。在终端中,cd到此目录并键入ant。它将下载并安装build.xml中定义的依赖项。该文件的内容应为

<project name="localrepository" default="install" xmlns:ivy="antlib:org.apache.ivy.ant">
 <target name="install" description="--> install modules to localreporsitory">
  <ivy:install organisation="TYPE HERE ORGANISATION" module="TYPE HERE THE MODULE"
   revision="TYPE HERE THE REVISION" transitive="true" overwrite="true" 
   from="public" to="local" />
 </target>
</project>

我先用它

让我们使用第一个给我带来问题的依赖作为例子。激活者报告说依赖是org.scala-lang #scala-library; 2.10.4。因为它遵循模型组织#module; revision,我们用于安装此依赖项的build.xml文件将是

<project name="localrepository" default="install" xmlns:ivy="antlib:org.apache.ivy.ant">
 <target name="install" description="--> install modules to localreporsitory">
  <ivy:install organisation="org.scala-lang" module="scala-library"
   revision="2.10.4" transitive="true" overwrite="true" 
   from="public" to="local" />
 </target>
</project>

答案 1 :(得分:0)

尝试使用Java 8.根据https://www.playframework.com/download,您需要JDK8。

我也遇到了Fedora 22和游戏的问题。我在某地读过Fedora中有一个错误。我无法修复它:(

答案 2 :(得分:0)

我遇到了类似的问题。我删除了所有名为&#34; scala-lang *&#34;的目录。在.ivy和.maven下,重新运行sbt compile。在sbt下载了依赖项之后,情况进展顺利。

答案 3 :(得分:0)

尝试删除缓存文件夹 Localhost 中的“org.scala-lang”