Scala play - “not found: value routes” (Eclipse and IDEA)

前端 未结 7 1957
一整个雨季
一整个雨季 2021-02-20 10:46

Occasionally, and seemingly for no reason, I get \"not found: value routes\" compilation error in one of the view templates (after compilation). This happens either in Eclipse o

相关标签:
7条回答
  • 2021-02-20 10:55

    I have this working defining an Asset Controller

    object Assets extends controllers.AssetsBuilder
    

    and having the route for assets too in the routes conf:

    \#Map static resources from the /public folder to the /assets URL path
    GET     /assets/*file          premise.internet_org.controllers.Assets.at(path="/public", file)
    
    0 讨论(0)
  • 2021-02-20 10:58

    This happens when there is no route configuration for your Assets in the routes file.

    You must add this to your routes file:

    GET   /assets/*file  controllers.Assets.at(path="/public", file)
    
    0 讨论(0)
  • 2021-02-20 11:00

    This can happen if the routes file does not exist or contains no routes.

    0 讨论(0)
  • 2021-02-20 11:03
    sbt compile
    

    Then IntelliJ loads the output of the compilation and everything just works for me.

    0 讨论(0)
  • 2021-02-20 11:07

    Since there seems to be no answer, I'll at-least describe my workaround: Instead of using

    <link href=@routes.Assets.at("stylesheets/style.css") rel="stylesheet" type="text/css" />
    

    in my template HTML, I'm using

    <link href="assets/stylesheets/styles.css") rel="stylesheet" type="text/css" />
    

    Since I'm not invoking routes.Assets.at, there is no issue with not finding the value routes. (However, I'm guessing this workaround will easily crumble when I would have need of more complex templates)

    0 讨论(0)
  • 2021-02-20 11:20

    I had to go to the terminal and type "activator test" before Intellij would stop giving me these errors during IDE tests.

    0 讨论(0)
提交回复
热议问题