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>

原文地址:https://www.cnblogs.com/yaowan/p/8984699.html

时间: 2024-12-21 23:17:21

maven 搭建spring框架报找不到applicationContext-*.xml文件的相关文章

Maven项目搭建(二):Maven搭建SSM框架

        上一章给大家讲解了如何使用Maven搭建web项目.       这次给大家介绍一下怎么使用Maven搭建SSM框架项目.       首先我们来看一下pom.xml的属性介绍: project: pom的xml根元素. parent:  声明继承. modules:  声明聚合,该值是一个当前POM的相对目录.用户项目的聚合. groupId:  定义当前Maven项目隶属的实际项目. artifactId:  定义实际项目中的一个Maven项目模块,一般为实际项目名称. ve

使用maven搭建ssm框架的javaweb项目

目前主流的javawe项目,常会用到ssm(Spring+Spring MVC+Mybatis)框架来搭建项目的主体框架,本篇介绍搭建SSM矿建的maven项目的实施流程.记之共享! 一.SSM框架介绍 SSM框架是指:Spring+Spring MVC+Mybatis. [Spring] 轻量--从大小与开销两方面而言Spring都是轻量的,此外,Spring是非侵入式的:典型地,Spring应用中的对象不依赖于Spring的特定类.简单说就是自己需要什么就导入对应的jar的即可,而不是侵入式

Spring框架学习之--搭建spring框架

此文介绍搭建一个最最简单的spring框架的步骤 一.创建一个maven项目 二.在pom.xml文件中添加依赖导入spring框架运行需要的相关jar包 注意:在引入jar包之后会出现org.junit里面的包无法使用,参考https://blog.csdn.net/he99774/article/details/78254262 <dependencies> <!-- 框架运行时的基本依赖 --> <dependency> <groupId>junit&

Maven搭建Spring+Struts2+Hibernate项目详解

前言 这篇主要采用Maven搭建Spring+Struts2+Hibernate的整合项目,复习一下SSH框架,虽然spring提供自己的MVC框架,但是Spring也提供和其他框架的无缝整合,采用组件形式对个框架进行管理,项目实例是按照真实企业里面的开发搭建,也是web的最后一片了.数据库使用mysql,连接池使用的是Druid数据源(这些都无关紧要,可以随时的替换),下面就将详细的介绍一下Maven搭建Spring,Struts2,和hibernation的步奏. 1.数据库设计 数据库库表

Maven 搭建spring boot多模块项目

Maven 搭建spring boot多模块项目 备注:所有项目都在idea中创建 1.idea创建maven项目 1-1: 删除src,target目录,只保留pom.xml 1-2: 根目录pom.xml可被子模块继承,因此项目只是demo,未考虑太多性能问题,所以将诸多依赖 都写在根级`pom.xml`,子模块只需继承就可以使用. 1-3: 根级pom.xml文件在附录1 1-4: 依赖模块 mybatis spring-boot相关模块 2.创建子模块(module) 2-1: file

Maven搭建Spring Security3.2项目详解

前言 本来是打算在上一篇SpringMVC+Hibernate上写的,结果发现上面那篇一起整合的,结果发现上一篇内容实在是太长了,就另起一篇,这篇主要是采用 Maven搭建Spring+SpringMVC+Hibernate+Security整合,而Spring+SpringMVC+Hibernate已经在上一篇介绍了,在这篇将不再重复写了,主要说明一下SpringSecurity3.2权限控制整合搭建,以及配置,使用注意事项等. SpringSecurity的Api文档地址:查看 1.Mave

maven搭建spring项目pom有关配置说明

<dependency>            <groupId>org.springframework</groupId>            <artifactId>spring-context-support</artifactId>            <version>${spring.version}</version>        </dependency> maven搭建spring项目p

maven搭建spring项目

开发工具:MyEclipse2014版(jdk1.7)+Maven3.9.  新建Maven项目:        Step1: Step2: Step3:这里选maven-archetype-webapp,因为后面的项目讲解都是web项目.如果是纯java项目,可以选择 maven-archetype-quickstart.   Step4: Step5:右键项目,build path,修改jdk运行环境. 到这里,maven的web项目初建完毕. 修改:pom.xml <project xml

spring 以Ant Build方式运行build.xml文件,报warning: &#39;includeantruntime&#39; was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds 的解决办法

Buildfile: F:\experience\spring_pdf\sourcecode\example1\build.xml compile: [javac] F:\experience\spring_pdf\sourcecode\example1\build.xml:25: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable