2014-09-22 21 views
0

您好,我在將Form Framework 2.2.2遷移到2.3.1版本時遇到Assets問題。除了我的班級資產外,一切都很好。我正在閱讀遊戲遷移指南,並試圖一步一步做這件事,但我仍然不知道如何去做。爲什麼從2.2.2遷移到2.3.1後,我的網絡應用程序無法工作?

我很抱歉做了一個很大的帖子,但我想盡可能地解釋它。

遷移之前一切都wroking好,當我進入本地主機:9000 我在這裏寫的(之前,我有我的網頁)

編譯錯誤 錯誤:方法在類資產不能用於給定類型;

public class AssetsController extends Controller { 

9 public static Action<AnyContent> at(String path, String file) { 

10  return Assets.at(path, file); 

11 } 

我奔跑嬉戲〜調試

[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:218: patterns 
after a variable pattern cannot match (SLS 8.1.1) 
[warn] If you intended to match against parameter file of method at, you must use 
backticks, like: case `file` => 
[warn] GET   /*file             
controllers.Assets.at(path="/public", file) 
[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:18: unreachable code due to variable pattern 'file' on line 279 
[warn] If you intended to match against parameter file of method at, you must use backticks, like: case `file` => 
[warn] GET   /login             controllers.Assets.at(path="/public", file="login.html") 
[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:26: unreachable code due to variable pattern 'file' on line 279 
[warn] If you intended to match against parameter file of method at, you must use backticks, like: case `file` => 
[warn] GET   /page/import           controllers.Assets.at(path="/public", file="import.html") 
[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:6: unreachable code due to variable pattern 'file' on line 279 
[warn] If you intended to match against parameter file of method at, you must use backticks, like: case `file` => 
[warn] GET   /              controllers.Assets.at(path="/public", file="index.html") 
[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:18: unreachable code 
[warn] GET   /login             controllers.Assets.at(path="/public", file="login.html") 
[warn] 5 warnings found 
[error] /home/myproject/NewProjectChange/workspace/play-angular/app/controllers/AssetsController.java:10: error: method at in class Assets cannot be applied to given types; 
[error]   return Assets.at(path, file); 
[error]     ^
[error] required: String,String,boolean 
[error] found: String,String 
[error] reason: actual and formal argument lists differ in length 
[error] /home/myproject/NewProjectChange/workspace/play-angular/app/controllers/AssetsController.java:14: error: method at in class Assets cannot be applied to given types; 
[error]   return Assets.at(path, file); 
[error]     ^
[error] required: String,String,boolean 
[error] found: String,String 
[error] reason: actual and formal argument lists differ in length 
[error] /home/myproject/NewProjectChange/workspace/play-angular/app/controllers/AssetsController.java:18: error: method at in class Assets cannot be applied to given types; 
[error]   return Assets.at(path, file); 
[error]     ^
[error] required: String,String,boolean 
[error] found: String,String 
[error] reason: actual and formal argument lists differ in length 
[error] /home/myproject/NewProjectChange/workspace/play-angular/app/controllers/AssetsController.java:22: error: method at in class Assets cannot be applied to given types; 
[error]   return Assets.at(path, file); 
[error]     ^
[error] required: String,String,boolean 
[error] found: String,String 
[error] reason: actual and formal argument lists differ in length 

我build.sbt文件看起來像時得到終端的錯誤:

name := "error" 

version := "2.3.1" 

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

scalaVersion := "2.11.1" 

crossScalaVersions := Seq("2.11.1", "2.10.4") 

doc in Compile <<= target.map(_/"none") 

libraryDependencies ++= Seq(
    javaJdbc, 
    javaEbean, 
    cache, 
"com.typesafe.play.plugins" %% "play-plugins-util" % "2.3.0", 
"com.typesafe.play.plugins" %% "play-plugins-mailer" % "2.3.0" 
) 

libraryDependencies += javaWs 

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.24" 

libraryDependencies += "org.fusesource.scalate" % "scalate-core" % "1.5.3" 

libraryDependencies += "net.sf.opencsv" % "opencsv" % "2.3" 

libraryDependencies += "org.apache.thrift" % "libthrift" % "0.9.1" 

libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.2" 

libraryDependencies += "org.apache.httpcomponents" % "httpcore" % "4.2" 

libraryDependencies += "org.codehaus.jackson" % "jackson-core-asl" % "1.1.0" 

libraryDependencies += "org.apache.commons" % "commons-lang3" % "3.3.1" 

而且我plugins.sbt樣子:

// Comment to get more information during initialization 
logLevel := Level.Warn 

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

// The Typesafe snapshot repository 
resolvers += "Typesafe snapshots" at "http://repo.typesafe.com/typesafe/snapshots/" 

// Use the Play sbt plugin for Play projects 
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.1") 

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.0") 

addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.0.0") 

addSbtPlugin("com.typesafe.sbt" % "sbt-webdriver" % "1.0.0") 

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0") 

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.0.0") 

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.1") 

我的路線例子e看起來像:

# Map static resources from the /public folder to the /assets URL path 
GET   /*file             controllers.Assets.at(path="/public", file) //line 218 
GET   /              controllers.Assets.at(path="/public", file="index.html") //line 6 
GET   /companies            controllers.Assets.at(path="/public", file="index.html") 
GET   /login             controllers.Assets.at(path="/public", file="login.html") //line 18 

我顯示線條什麼給警告。

我花了很多時間試圖修復它我已經解決了很多其他問題,並取得了良好的結果,但他與我投降。

我會非常感謝您的幫助。

回答

3

錯誤消息的原因很明顯,在您的代碼中,您使用兩個參數調用Assets.at方法。不過Assets.at的簽名是;

public static Action<AnyContent> at(String path, 
            String file, 
            boolean aggressiveCaching) 

這需要三個參數。所以你需要提供一個布爾值作爲你的調用的第三個參數以擺脫錯誤信息。

另一方面,我想知道AssetsController類的目的。你似乎沒有在你的路線中使用它。

關於警告信息;我的建議是用更具體的東西替換GET /*file規則。由於此規則將匹配所有請求,所以在此之後聲明的任何規則都不會匹配。然後在路由文件末尾聲明GET /*file規則指向返回404響應。

+0

它幫了我很多!謝謝 :) – Kox 2014-09-23 15:21:44

1

只是猜測,但線條看起來可疑:

[warn] /home/myproject/NewProjectChange/workspace/play-angular/conf/routes:218: 
patterns after a variable pattern cannot match (SLS 8.1.1) 
[warn] If you intended to match against parameter file of method at, you must 
use backticks, like: case `file` => 
[warn] GET /*file controllers.Assets.at(path="/public", file) 

的方法controllers.Assets.at的簽名是:

def at(path: String, file: String, aggressiveCaching: Boolean = false): Action[AnyContent] 

注意file輸入參數。

我想這可能與路線搞亂:

GET /*file controllers.Assets.at(path="/public", file) 

file定義爲圖案。

我認爲file模式和file輸入參數衝突,因此問題。我不確定它有多大幫助,我希望我不會再造成任何傷害。

0

我遇到了同樣的問題。您可以按照here所述的方法重新訂購路線,以解決問題。

我嘗試了添加第三個aggressiveCaching參數的建議,但是這只是在我的路由文件中引起了紅色的波浪曲線。

相關問題