解决Spring Boot OTS parsing error: Failed to convert WOFF 2.0

在项目中为了方便配置,通常会使用properties文件保存配置信息,项目启动时,需要maven开启filtering用properties中的属性值替换掉配置文件中的占位符,比如我的项目中使用c3p0.properties文件保存数据库的连接信息,这样我每次需要修改数据库的连接信息时,只需要修改c3p0.properties中的文件即可,在mybatis-config.xml中使用${}读取值(见下图),使用maven的resource插件开启filtering,在编译时就会将XML文件中的${}替换为properties的内容。



在使用Spring Boot时,我的页面相关的文件都是放在src/resource/目录下,启动项目后,页面的图标(使用的是font-awesome)就无法使用了,查看了官方文档解释如下:

也就是说,使用maven的resource插件开启filtering功能后,会破坏有二进制内容的文件。

按照官方的文档需要修改配置为如下内容(本项目为例):

[html]  view plain  copy
  1. <resources>  
  2.             <resource>  
  3.                 <directory>${project.basedir}/src/main/resources</directory>  
  4.                 <filtering>true</filtering>  
  5.                 <excludes>  
  6.                     <exclude>static/fonts/**</exclude>  
  7.                 </excludes>  
  8.             </resource>  
  9.             <resource>  
  10.                 <directory>${project.basedir}/src/main/resources</directory>  
  11.                 <filtering>false</filtering>  
  12.                 <includes>  
  13.                     <include>static/fonts/**</include>  
  14.                 </includes>  
  15.             </resource>  
  16.         </resources>  
static目录部分内容:


这样项目编译之后,文件就不会被破坏了。

猜你喜欢

转载自blog.csdn.net/UncleTian/article/details/79818295