我下载了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 已注册 这条路径指向这里:
路径对我来说看起来不错。
有谁知道缺少什么或问题出在哪里阻止 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/