我有瀏覽器緩存的問題,所以我決定改變斯卡拉玩`@ routes.Assets.versioned`導致非描述性錯誤
<script type="text/javascript" src="@routes.Assets.at("/accounts/dist/inline.bundle.js")"></script>
到
<script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")"></script>
因爲我們已經做在其他項目中,但我得到這完全無益的錯誤:
C:\work\FrontServices\Spike2>sbt -jvm-debug 9999 run
"C:\Users\xavier\.sbt\preloaded\org.scala-sbt\sbt\"1.0.2"\jars\sbt.jar"
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF8
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Listening for transport dt_socket at address: 58387
[warn] Executing in batch mode.
[warn] For better performance, hit [ENTER] to switch to interactive mode, or
[warn] consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from C:\Users\xavier\.sbt\0.13\staging\560eb781744c869bfbb7\sbt-coveralls\project
[info] Loading project definition from C:\work\FrontServices\Spike2\project
[info] Set current project to Spike2 (in build file:/C:/work/FrontServices/Spike2/)
[info] Compiling 1 Scala source to C:\work\FrontServices\Spike2\modules\accounts\target\scala-2.11\classes...
[error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:20: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call
[error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","inline.bundle.js")"></script>
[error] ^
[error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:21: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call
[error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","polyfills.bundle.js")"></script>
[error] ^
[error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:22: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call
[error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","styles.bundle.js")"></script>
[error] ^
[error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:23: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call
[error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","vendor.bundle.js")"></script>
[error] ^
[error] C:\work\FrontServices\Spike2\modules\accounts\app\com\newswhip\accounts\views\accounts.scala.html:24: too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call
[error] <script type="text/javascript" src="@routes.Assets.versioned("/public/accounts/dist","main.bundle.js")"></script>
[error] ^
[error] 5 errors found
[error] (accounts/compile:compileIncremental) Compilation failed
[error] Total time: 4 s, completed 20-Oct-2017 10:27:09
C:\work\FrontServices\Spike2>
這是從代碼片段文件
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path = "/public/accounts/dist", file: Asset)
# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.at(path = "/public", file)
任何想法?
我傳遞2個參數的int版本,因爲我們都已經在做了成功的其他2個項目。除了路徑文件在'GET/assets/*文件controllers.Assets.versioned(path =「/ public/accounts/dist」,file:Asset)中有這樣的一行外,所以版本化可能需要2個參數。我已經嘗試將param合併到1字符串中,就像用於' - 剛剛用'版本'代替'at',但編譯時出現「noSuchMethod + controllers.ReverseAssets.versioned」錯誤。 – codeepic
確切的錯誤是從線程[application-akka.actor.default-dispatcher-6]的未捕獲錯誤關閉JVM,因爲爲ActorSystem [application] java啓用了'akka.jvm-exit-on-fatal-error'。 lang.NoSuchMethodError:controllers.ReverseAssets.versioned(Lcontrollers/Assets $ Asset;)Lplay/api/mvc/Call;' – codeepic
好的,嘗試從版本中刪除已經在路由中給出的路徑。我的意思是,在路由中你指定了路徑爲'/ public/accounts/dist',然後在代碼中訪問時刪除這部分。嘗試使用 - 'src =「@ routes.Assets.versioned(」inline.bundle.js「)」'。我希望它能起作用! –