java - Symfony2 Assets :dump | error Output: "The system cannot find the path specified"

标签 java symfony assetic yui-compressor

我下载了yuicompressor-2.4.8.jar并将其放置在 app/Resources/java/ 文件夹中。

接下来,我在我的 Twig 模板中创建了 {% stylesheets %} block ,如下例所示:

{% stylesheets 
    'bundles/arsen/css/style.css'
    filter='cssrewrite, yui_css'
    output='assets/css/complied.css'
%}
    <link rel="stylesheet" type="text/css" href="{{ asset_url }}">
{% endstylesheets %}

当我运行 app/console assetic:dump 时,出现以下错误:

  "/usr/bin/java" "-jar" "C:\xampp\htdocs\Symfony27\app/Resources/java/yuicompressor-2.4.8.jar" "--charset" "UTF-8" "-o" "C:\Users\SYMFONY\AppData\Local\Temp\ass2341.tmp" "--type" "css" "C:\Users\SYMFONY\AppData\Local\Temp\ass2340.tmp"
  Error Output:                                                                                                                                                                                                   
  The system cannot find the path specified.  

据我所知,我安装了 java jre 并且可以从命令行访问 java:

$ java -version
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) Client VM (build 25.73-b02, mixed mode, sharing)

在我的 Windows 路径中,我有: C:\ProgramData\Oracle\Java\javapath 已注册 这条路径指向这里: enter image description here

路径对我来说看起来不错。 有谁知道缺少什么或问题出在哪里阻止 app/console assetic:dump 命令工作?

也许此设置会导致问题app/config/config.yml:

assetic:
    #...
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        yui_css:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.8.jar"
            #...

最佳答案

如 symfony 文档所述:

Windows users need to remember to update config to proper Java location.
In Windows7 x64 bit by default it's C:\Program Files (x86)\Java\jre6\bin\java.exe.

实际上,该命令正在寻找位于 /usr/bin/java 中的可执行文件,而 Windows 上不存在该可执行文件。

此外,您必须在 Assets 配置中注册您的 java 路径:

assetic:
    # ...
    java: C:\Program Files (x86)\Java\jre7\bin\java.exe

请参阅YUI Compressor文档的一部分。

关于java - Symfony2 Assets :dump | error Output: "The system cannot find the path specified",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35339672/

相关文章:

unit-testing - Symfony2 : Mocked service is set in the container but not used by the controller (it still uses the original service)

php - Symfony 2.8 和 PHP 7.4 : Warning: "continue" targeting switch is equivalent to "break". Composer 是最新版本

javascript - Symfony2 : JavaScript doesn't work on Prod environment

php - 即使不再引用文件,Assetic 文件不存在错误?

java - 未处理的异常类型 ClassNotFoundException

java - Google Drive API 401 未经授权错误

php - 实体的 Doctrine2 动态表名

php - Assets 未显示在开发环境中

Java BigInteger 内存不足,可能来自长转换

java - 我应该将不被视为资源的配置文件放在 maven 项目的路径中的哪个位置