問題描述
今天在啟動專案時,發現網頁的圖示都加載不出來,打開控制臺,發現告警資訊是檔案解碼錯誤,錯誤資訊:
- Failed to decode downloaded font: http://localhost:8080/plugins/fontawesome-free/webfonts/fa-solid-900.woff2
- OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
- OTS parsing error: incorrect file size in WOFF header
- OTS parsing error: incorrect entrySelector for table directory
如下圖:


原因分析
maven打包時:會編譯專案檔案,如果存在不需要編譯的檔案需要在配置里面排除,因為有些資源檔案被編譯后會與原檔案不同,導致檔案不可用,
問題解決
添加 maven 資源檔案管理插件 maven-resources-plugin,指定不過濾的檔案擴展名,
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- 不過濾字體檔案 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>ttf</nonFilteredFileExtension>
<nonFilteredFileExtension>woff</nonFilteredFileExtension>
<nonFilteredFileExtension>woff2</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</plugin>
</plugins>
</build>

圖示正常加載出來了,控制臺也沒有告警錯誤資訊,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/258662.html
標籤:其他
