如何配置注解版Spring mvc 工程
1.创建maven工程
删除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>