使用maven 編譯WEB項目時,按鈕上的圖標不顯示(使用http://fontawesome.io/icons/)
在瀏覽器console中打印錯誤:OTS parsing error: incorrect entrySelector for table directory 1 Failed to decode downloaded font: https://my-address.com/css/fonts/robot...
原因:使用maven-resources-plugin copy 靜態資源時,如果有<filtering>true</filtering>標簽,會破壞fontawesome 中的文件
<resources>
<resource>
<directory>${project.basedir}/src/main/webapp</directory>
<targetPath>${project.build.directory}</targetPath>
<filtering>true</filtering>
</resources>
解決辦法:
(1) 將 <filtering>true</filtering> 改為false
(2)
<resources>
<resource>
<directory>${project.basedir}/src/main/webapp</directory>
<targetPath>${project.build.directory}</targetPath>
<filtering>true</filtering>
<excludes>
<exclude>**/*.woff</exclude>
<exclude>**/*.ttf</exclude>
<exclude>**/*.woff2</exclude>
<exclude>**/*.otf</exclude>
<exclude>**/*.eot</exclude>
<exclude>**/*.svg</exclude>
</excludes>
</resource>
<resource>
<directory>${project.basedir}/src/main/webapp</directory>
<targetPath>${project.build.directory}</targetPath>
<filtering>false</filtering>
<includes>
<include>**/*.woff</include>
<include>**/*.ttf</include>
<include>**/*.woff2</include>
<include>**/*.otf</include>
<include>**/*.eot</include>
<include>**/*.svg</include>
</includes>
</resource>
</resources>
參考:http://stackoverflow.com/questions/32690418/i-cant-load-fonts-while-using-tomcat
http://stackoverflow.com/questions/32475982/fontawesome-fails-to-load-fonts-locally-and-in-electron-app
