SpringBoot项目启动后,访问页面发现字体图标不显示,打开控制台看到如下报错
Failed to decode downloaded font: URL
OTS parsing error: incorrect file size in WOFF header
Failed to decode downloaded font: URL
OTS parsing error: incorrect entrySelector for table directory
OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
原因在于前端页面使用了外部字体,如FontAwesome、Nucleo等,在Maven Build的时候,Maven把字体文件当作前端资源文件压缩了。需要进行两步配置:
在存放前端资源文件的web模块的pom.xml加入如下代码:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>