java.io.IOException:无法从'http:// localhost:19001 / assets / javascripts / jquery-1.9.0.min.js'下载JavaScript(状态404)

时间:2016-03-21 21:19:33

标签: scala intellij-idea playframework-2.5

我知道很多人会说这是在另一个帖子上得到了解答,但我还没有找到这个问题的答案。线程被劫持,或修复不起作用。

我正在使用IntelliJ IDEA 2016.1 Build#IU-145.258,建于2016年3月17日

My Project SDK为1.8.0_73,Scala版本为2.11,Play 2版本为2.5.0。

我正在通过右键单击项目的测试文件夹从IDE运行测试,然后单击Debug'All Tests'。它们都通过了,但是我收到了以下错误。

java.io.IOException: Unable to download JavaScript from 'http://localhost:19001/assets/javascripts/jquery-1.9.0.min.js' (status 404).

在IntegrationSpec.scala中发生IOException。任何人都可以帮忙解决这个问题吗?

这是我项目的文件。

提前感谢你

弗朗西斯

build.sbt

name := "test"

version := "1.0"

lazy val `test` = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.7"

libraryDependencies ++= Seq( jdbc , cache , ws   , specs2 % Test )

unmanagedResourceDirectories in Test <+=  baseDirectory ( _ /"target/web/public/test" )  

resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"  

路由

# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET     /                           controllers.Application.index

# Map static resources from the /public folder to the /assets URL path
GET     /assets/*file               controllers.Assets.at(path="/public", file)

build.properties

sbt.version=0.13.5

plugins.sbt

logLevel := Level.Warn

resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.5.0")

Application.scala

package controllers

import play.api._
import play.api.mvc._

class Application extends Controller {

  def index = Action {
    Ok(views.html.index("Your new application is ready."))
  }

}

main.scala.html

@(title: String)(content: Html)

<!DOCTYPE html>

<html>
    <head>
        <title>@title</title>
        <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
        <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
        <script src="@routes.Assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script>
    </head>
    <body>
        @content
    </body>
</html>

IntegrationSpec.scala

import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._

import play.api.test._
import play.api.test.Helpers._

/**
 * add your integration spec here.
 * An integration test will fire up a whole play application in a real (or headless) browser
 */
@RunWith(classOf[JUnitRunner])
class IntegrationSpec extends Specification {

  "Application" should {

    "work from within a browser" in new WithBrowser {

      browser.goTo("http://localhost:" + port)

      browser.pageSource must contain("Your new application is ready.")
    }
  }
}

0 个答案:

没有答案