注意事項

注意事項:

1. Maven中使用Mybatis時,DAO工程下mapper映射文件無法加載到classpath中。

pom.xml中加入如下代碼

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

ps:一旦使用這種方式將資源文件加載到classpath下,此時resources目錄下的資源文件不會自動加載到classpath下,故需要以同種方式進行配置。

2. 靜態資源映射

在spring.xml中加入如下代碼

<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>
<mvc:resources location="/WEB-INF/images/" mapping="/images/**"/>

此時,靜態資源文件的放置位置位於/WEB-INF/下。

發佈了39 篇原創文章 · 獲贊 14 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章