在Spring Boot/Spring MVC应用程序中,字体无法正常工作的问题.
问题是所有字体文件都显示各种错误,如下所示
Failed to decode downloaded font: http://localhost:8080/fonts/fontawesome-webfont.woff2?v=4.4.0 OTS parsing error: Failed to convert WOFF 2.0 font to SFNT Failed to decode downloaded font: http://localhost:8080/fonts/fontawesome-webfont.woff?v=4.4.0 OTS parsing error: incorrect file size in WOFF header Failed to decode downloaded font: http://localhost:8080/fonts/fontawesome-webfont.ttf?v=4.4.0 OTS parsing error: incorrect entrySelector for table directory
code.. 28
问题是Maven正在过滤字体文件并破坏它们.
${project.basedir}/src/main/resources true
修复是对以下内容进行以下更改 pom.xml
${project.basedir}/src/main/resources true static/fonts/** ${project.basedir}/src/main/resources false static/fonts/**
此更改允许在打包期间不过滤字体.
问题是Maven正在过滤字体文件并破坏它们.
${project.basedir}/src/main/resources true
修复是对以下内容进行以下更改 pom.xml
${project.basedir}/src/main/resources true static/fonts/** ${project.basedir}/src/main/resources false static/fonts/**
此更改允许在打包期间不过滤字体.
另一种方法是更新maven-resources-plugin的配置,如下所示:
org.apache.maven.plugins maven-resources-plugin ttf woff woff2