Играть! 2.3.1 - main.css 404 (публичные активы не маршрутизируются?)

Я просто загрузил Play Java Seed из пользовательского интерфейса, чтобы создать новое приложение. Я написал код CSS в public/stylesheets/main.css, и это единственное изменение, которое я внес в этот проект. После компиляции и запуска приложения консоль Chrome сообщает

GET http://localhost:9000/assets/stylesheets/main.css 404 (Not Found)
GET http://localhost:9000/assets/javascripts/hello.js 404 (Not Found) 

Я прочитал документацию контроллера контроллера здесь, но не могу понять, где я ошибаюсь.

В моем main.scala.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/hello.js")" type="text/javascript"></script>
</head>

И в моем файле маршрутов (также неизменным от семени):

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

Флажок появляется на вкладке, но когда я перехожу к http://localhost:9000/assets/images/favicon.png, страница также недоступна, как и с main.css и hello.js script.

Ответ 1

Это также происходит (в игре 2.3.8) при запуске из упакованного tarball, созданного с помощью

$ activator universal:package-zip-tarball

то..

$ [tarball-extract-path]/bin/[project-name]

На локальном dev build файлы загружаются нормально, но на удаленном тестовом сервере я получаю 404 (не найден).

Ответ 2

Для меня проблема исчезает, когда я запускаю свой проект для производства:

activator start

Это всего лишь обходной путь, но я надеюсь, что это поможет некоторым из вас.

Я подозреваю, что это ошибка в игре, и, надеюсь, будет выпущена новая версия игры.

Ответ 3

Если у вас есть LessKeys.compress := true в вашей сборке, вы должны использовать сокращенную версию.

@routes.Assets.at("stylesheets/main.min.css")

Ответ 4

У меня нет проблем с запуском Play Java Seed, загруженного из typesafe.com, который использует PlayFramework 2.3.7

Посмотрите, что я сделал и делаю то же самое

$ unzip play-java.zip 
  Archive:  play-java.zip
  inflating: play-java/conf/application.conf  
  inflating: play-java/conf/routes   
  inflating: play-java/README        
  inflating: play-java/activator     
  inflating: play-java/app/views/main.scala.html  
  inflating: play-java/app/views/index.scala.html  
  inflating: play-java/app/controllers/Application.java  
  inflating: play-java/test/ApplicationTest.java  
  inflating: play-java/test/IntegrationTest.java  
  inflating: play-java/project/plugins.sbt  
  inflating: play-java/project/build.properties  
  inflating: play-java/LICENSE       
  inflating: play-java/.gitignore    
  inflating: play-java/public/stylesheets/main.css  
  inflating: play-java/public/javascripts/hello.js  
  inflating: play-java/public/images/favicon.png  
  inflating: play-java/build.sbt     
  inflating: play-java/activator.bat  
  inflating: play-java/activator-launch-1.2.12.jar  

$ cd play-java/

$ ls
activator*  activator.bat*  activator-launch-1.2.12.jar  app/  build.sbt  conf/  LICENSE      project/  public/  README  test/

$ activator run
[info] Loading project definition from /home/skierat/Documents/dev/projects/typesafe/play-java/project
[info] Updating {file:/home/skierat/Documents/dev/projects/typesafe/play-java/project/}play-java-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] downloading http://repo.typesafe.com/typesafe/ivy-releases/com.typesafe.play/sbt-plugin/scala_2.10/sbt_0.13/2.3.7/jars/sbt-plugin.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#sbt-plugin;2.3.7!sbt-plugin.jar (3451ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/build-link/2.3.7/build-link-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#build-link;2.3.7!build-link.jar (534ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-exceptions/2.3.7/play-exceptions-2.3.7.jar ...                                                                                                         
[info]  [SUCCESSFUL ] com.typesafe.play#play-exceptions;2.3.7!play-exceptions.jar (527ms)                                                                                                                                                   
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/routes-compiler_2.10/2.3.7/routes-compiler_2.10-2.3.7.jar ...                                                                                               
[info]  [SUCCESSFUL ] com.typesafe.play#routes-compiler_2.10;2.3.7!routes-compiler_2.10.jar (2230ms)                                                                                                                                        
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/sbt-run-support_2.10/2.3.7/sbt-run-support_2.10-2.3.7.jar ...                                                                                               
[info]  [SUCCESSFUL ] com.typesafe.play#sbt-run-support_2.10;2.3.7!sbt-run-support_2.10.jar (652ms)                                                                                                                                         
[info] Done updating.                                                                                                                                                                                                                       
[info] Set current project to play-java (in build file:/home/skierat/Documents/dev/projects/typesafe/play-java/)                                                                                                                            
[info] Updating {file:/home/skierat/Documents/dev/projects/typesafe/play-java/}root...                                                                                                                                                      
[info] Resolving jline#jline;2.11 ...
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play_2.11/2.3.7/play_2.11-2.3.7.jar ...                                                                                                                     
[info]  [SUCCESSFUL ] com.typesafe.play#play_2.11;2.3.7!play_2.11.jar (6448ms)                                                                                                                                                              
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-java_2.11/2.3.7/play-java_2.11-2.3.7.jar ...                                                                                                           
[info]  [SUCCESSFUL ] com.typesafe.play#play-java_2.11;2.3.7!play-java_2.11.jar (768ms)                                                                                                                                                     
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-java-jdbc_2.11/2.3.7/play-java-jdbc_2.11-2.3.7.jar ...                                                                                                 
[info]  [SUCCESSFUL ] com.typesafe.play#play-java-jdbc_2.11;2.3.7!play-java-jdbc_2.11.jar (550ms)                                                                                                                                           
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-java-ebean_2.11/2.3.7/play-java-ebean_2.11-2.3.7.jar ...                                                                                               
[info]  [SUCCESSFUL ] com.typesafe.play#play-java-ebean_2.11;2.3.7!play-java-ebean_2.11.jar (655ms)                                                                                                                                         
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-cache_2.11/2.3.7/play-cache_2.11-2.3.7.jar ...                                                                                                         
[info]  [SUCCESSFUL ] com.typesafe.play#play-cache_2.11;2.3.7!play-cache_2.11.jar (775ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-java-ws_2.11/2.3.7/play-java-ws_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-java-ws_2.11;2.3.7!play-java-ws_2.11.jar (661ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-iteratees_2.11/2.3.7/play-iteratees_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-iteratees_2.11;2.3.7!play-iteratees_2.11.jar (4162ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-json_2.11/2.3.7/play-json_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-json_2.11;2.3.7!play-json_2.11.jar (1627ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-functional_2.11/2.3.7/play-functional_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-functional_2.11;2.3.7!play-functional_2.11.jar (1132ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-datacommons_2.11/2.3.7/play-datacommons_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-datacommons_2.11;2.3.7!play-datacommons_2.11.jar (526ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-jdbc_2.11/2.3.7/play-jdbc_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-jdbc_2.11;2.3.7!play-jdbc_2.11.jar (891ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-ws_2.11/2.3.7/play-ws_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-ws_2.11;2.3.7!play-ws_2.11.jar (1746ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-test_2.11/2.3.7/play-test_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-test_2.11;2.3.7!play-test_2.11.jar (773ms)
[info] downloading http://repo.typesafe.com/typesafe/releases/com/typesafe/play/play-docs_2.11/2.3.7/play-docs_2.11-2.3.7.jar ...
[info]  [SUCCESSFUL ] com.typesafe.play#play-docs_2.11;2.3.7!play-docs_2.11.jar (8607ms)
[info] Done updating.

--- (Running the application, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

И окончательный тест:

$ curl -Is http://localhost:9000/assets/stylesheets/main.css | head -n 1

возвращает

HTTP/1.1 200 OK