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


問題原因:

早使用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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM