解决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功能后,会破坏有二进制内容的文件。

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

 

<resources>  
            <resource>  
                <directory>${project.basedir}/src/main/resources</directory>  
                <filtering>true</filtering>  
                <excludes>  
                    <exclude>static/fonts/**</exclude>  
                </excludes>  
            </resource>  
            <resource>  
                <directory>${project.basedir}/src/main/resources</directory>  
                <filtering>false</filtering>  
                <includes>  
                    <include>static/fonts/**</include>  
                </includes>  
            </resource>  
        </resources>  

 

static目录部分内容:

 

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

posted @ 2017-09-26 20:14  园芳宝贝  阅读(656)  评论(0编辑  收藏  举报