1. 程式人生 > >maven 搭建spring框架報找不到applicationContext-*.xml文件

maven 搭建spring框架報找不到applicationContext-*.xml文件

lte 重新 ID -- 直接 dao 成了 war包 config

問題原因:

早使用maven搭建web工程時,並沒有進行分布式搭建,我是把pojo、dao、service、web 四層直接放在了一個父工程中,並沒有一個一個的子工程區分,而是直接打包成了一個war包

所以在搭建過程中出現了找不到spring的映射文件,web.xml文件報錯,

之後我百度了一下找到了這個配置,由重新執行了一下項目,就執行成功了

在工程的pom文件中添加以下代碼

<!-- 如果不添加此節點mybatis的mapper.xml文件都會被漏掉。 -->
    <build>
        <resources>
            <!--
如果不添加此節點mybatis的mapper.xml文件都會被漏掉。 --> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </
includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <
include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> <!-- 添加tomcat插件 --> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <configuration> <port>8081</port> <path>/</path> </configuration> </plugin> </plugins> </build>

maven 搭建spring框架報找不到applicationContext-*.xml文件