eclipse如何配置注解版spring mvc工程整合mybatis

本文档详细介绍了如何配置注解版的Spring MVC工程,包括创建Maven工程,引入Maven依赖,配置过滤器、DispatcherServlet、Spring容器和Spring MVC容器。特别强调了如何替代web.xml配置,以及Spring容器的配置,最后通过创建Controller测试了配置的正确性。
摘要由CSDN通过智能技术生成

如何配置注解版Spring mvc 工程

1.创建maven工程

选择webapp
删除web.xml 和index.jsp 要把pom.xml中加入 在

  <!-- 删除web.xml后 需要将poom.xml中failOnMissingWebXml设置成false  这是对web.xml的一个检查 -->
  <properties>
		<failOnMissingWebXml>false</failOnMissingWebXml>
  </properties>

2.引入maven依赖

我们这里引入的依赖与在配置xml中得依赖是一样得

 		 <!-- servlet-api -->
   		<dependency>
   			<groupId>javax.servlet</groupId>
   			<artifactId>javax.servlet-api</artifactId>
   			<version>3.1.0</version>
   			<scope>provided</scope>
   		</dependency>
   		
   		<!-- spring - webmvc -->
   		<dependency>
   			<groupId>org.springframework</groupId>
   			<artifactId>spring-webmvc</artifactId>
   			<version>5.2.2.RELEASE</version>
   		</dependency>
   		
   		<!-- spring thymeleaf的依赖 strat -->
   		<dependency>
   			<groupId>org.thymeleaf</groupId>
   			<artifactId>thymeleaf</artifactId>
   			<version>3.0.11.RELEASE</version>
   		</dependency>
   	
		<dependency>
		  <groupId>org.thymeleaf</groupId>
		  <artifactId>thymeleaf-spring5</artifactId>
		  <version>3.0.11.RELEASE</version>
		</dependency>
		<!-- thymeleaf end -->
   		
   		
   		<!-- jackson -->
   		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.9.5</version>
		</dependency>
   		
   		<!-- 事务 -->
   		<!-- spring-tx -->
   		<dependency>
   			<groupId>org.springframework</groupId>
   			<artifactId>spring-tx</artifactId>
   			<version>5.2.2.RELEASE</version>
   		</dependency>
   		
   		<!-- spring-jdbc  JdbcTemplate-->
   		<dependency>
   			<groupId>org.springframework</groupId>
   			<artifactId>spring-jdbc</artifactId>
   			<version>5.2.2.RELEASE</version>
   		</dependency>
   		
   		<!-- xml配置事务 另外加入以下三个依赖  不用以下三个依赖  因为没有xml了-->
   		<!-- spring-aspects -->	<!-- aspectjrt -->	<!-- aspectjweaver -->
   		<!--事务 end-->
   		
   		<!-- mybatis 与数据库之间的依赖  start -->
   		<!-- mysql -->
   		<dependency>
   			<groupId>mysql</groupId>
   			<artifactId>mysql-connector-java</artifactId>
   			<version>5.1.46</version>
   		</dependency>
   		
   		<!-- Druid  -->
   		<dependency>
   			<groupId>com.alibaba</groupId>
   			<artifactId>druid</artifactId>
   			<version>1.1.10</version>
   		</dependency>
   		
   		<!-- mybatis -->
   		<dependency>
   			<groupId>org.mybatis</groupId>
   			<artifactId>mybatis</artifactId>
   			<version>3.5.3</version>
   		
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值