利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解

http://blog.csdn.net/noaman_wgs/article/details/53893948

利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解

这两天在公司实习,师父让我先熟悉Intellij软件的使用和SpringMVC框架。话不多说,先利用这些搭建一个小环境吧。

1 创建MAVEN项目:File-NEW-MAVEN-create from..前打勾--选下面的org.apache..archetypes:maven-archetype-webapp,点击next

后面的项目名称:

GroupId:项目的名称,
ArtiFactId:项目的模块名称(建议用项目名称-模块名称来表示),
Version:项目版本的名称
如:groupID:SpringMVC;ArtiFactId:SpringMVC-Demo,version:默认完成后,IDEA就自动给我们构建了一个空的maven项目.

利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解

2  配置pom.xml文件,这里利用<dependency></dependency>标签导入需要的库。这里需要导入的有junit , spring , springmvc , mysql , mybatis , jstl等等,详见下面的配置文件:

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3. <modelVersion>4.0.0</modelVersion>
  4. <groupId>MybatisTest</groupId>
  5. <artifactId>MybatisTest-Demo1</artifactId>
  6. <packaging>war</packaging>
  7. <version>1.0-SNAPSHOT</version>
  8. <name>MybatisTest-Demo1 Maven Webapp</name>
  9. <url>http://maven.apache.org</url>
  10. <dependencies>
  11. <dependency>
  12. <groupId>junit</groupId>
  13. <artifactId>junit</artifactId>
  14. <version>3.8.1</version>
  15. <scope>test</scope>
  16. </dependency>
  17. <!--mysql driver-->
  18. <dependency>
  19. <groupId>mysql</groupId>
  20. <artifactId>mysql-connector-java</artifactId>
  21. <version>5.1.6</version>
  22. </dependency>
  23. <!--spring-->
  24. <!-- spring-aop -->
  25. <dependency>
  26. <groupId>org.springframework</groupId>
  27. <artifactId>spring-aop</artifactId>
  28. <version>4.3.5.RELEASE</version>
  29. </dependency>
  30. <!--spring-tx -->
  31. <dependency>
  32. <groupId>org.springframework</groupId>
  33. <artifactId>spring-tx</artifactId>
  34. <version>4.3.5.RELEASE</version>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework</groupId>
  38. <artifactId>spring-beans</artifactId>
  39. <version>4.3.1.RELEASE</version>
  40. </dependency>
  41. <dependency>
  42. <groupId>org.springframework</groupId>
  43. <artifactId>spring-core</artifactId>
  44. <version>4.3.1.RELEASE</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>org.springframework</groupId>
  48. <artifactId>spring-context</artifactId>
  49. <version>4.3.1.RELEASE</version>
  50. </dependency>
  51. <!--Spring Web + Spring MVC-->
  52. <dependency>
  53. <groupId>org.springframework</groupId>
  54. <artifactId>spring-web</artifactId>
  55. <version>4.3.1.RELEASE</version>
  56. </dependency>
  57. <dependency>
  58. <groupId>org.springframework</groupId>
  59. <artifactId>spring-webmvc</artifactId>
  60. <version>4.3.1.RELEASE</version>
  61. </dependency>
  62. <!--NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config-->
  63. <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
  64. <dependency>
  65. <groupId>javax.servlet</groupId>
  66. <artifactId>jstl</artifactId>
  67. <version>1.2</version>
  68. </dependency>
  69. <dependency>
  70. <groupId>taglibs</groupId>
  71. <artifactId>standard</artifactId>
  72. <version>1.1.2</version>
  73. </dependency>
  74. <!--servlet/jsp api start-->
  75. <dependency>
  76. <groupId>javax.servlet</groupId>
  77. <artifactId>servlet-api</artifactId>
  78. <version>2.5</version>
  79. </dependency>
  80. <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
  81. <dependency>
  82. <groupId>javax.servlet.jsp</groupId>
  83. <artifactId>jsp-api</artifactId>
  84. <version>2.2</version>
  85. </dependency>
  86. <!--c3p0-->
  87. <dependency>
  88. <groupId>com.mchange</groupId>
  89. <artifactId>c3p0</artifactId>
  90. <version>0.9.5.1</version>
  91. </dependency>
  92. <!--aspectj-->
  93. <dependency>
  94. <groupId>org.aspectj</groupId>
  95. <artifactId>aspectjweaver</artifactId>
  96. <version>1.8.6</version>
  97. </dependency>
  98. <dependency>
  99. <groupId>org.aspectj</groupId>
  100. <artifactId>aspectjrt</artifactId>
  101. <version>1.8.6</version>
  102. </dependency>
  103. <!--jdbc-->
  104. <dependency>
  105. <groupId>org.springframework</groupId>
  106. <artifactId>spring-jdbc</artifactId>
  107. <version>3.0.5.RELEASE</version>
  108. </dependency>
  109. <!--mybatis-->
  110. <dependency>
  111. <groupId>org.mybatis</groupId>
  112. <artifactId>mybatis</artifactId>
  113. <version>3.4.1</version>
  114. </dependency>
  115. <!--mybatis spring整合-->
  116. <dependency>
  117. <groupId>org.mybatis</groupId>
  118. <artifactId>mybatis-spring</artifactId>
  119. <version>1.3.0</version>
  120. </dependency>
  121. <dependency>
  122. <groupId>junit</groupId>
  123. <artifactId>junit</artifactId>
  124. <version>RELEASE</version>
  125. </dependency>
  126. <!--spring-test-->
  127. <dependency>
  128. <groupId>org.springframework</groupId>
  129. <artifactId>spring-test</artifactId>
  130. <version>3.2.3.RELEASE</version>
  131. <scope>test</scope>
  132. </dependency>
  133. <dependency>
  134. <groupId>org.springframework</groupId>
  135. <artifactId>spring-test</artifactId>
  136. <version>RELEASE</version>
  137. </dependency>
  138. </dependencies>
  139. <build>
  140. <finalName>MybatisTest-Demo1</finalName>
  141. <plugins>
  142. <!--servlet容器 jetty插件-->
  143. <plugin>
  144. <groupId>org.eclipse.jetty</groupId>
  145. <artifactId>jetty-maven-plugin</artifactId>
  146. <version>9.3.10.v20160621</version>
  147. </plugin>
  148. <!--mybatis 逆向工程插件-->
  149. <plugin>
  150. <groupId>org.mybatis.generator</groupId>
  151. <artifactId>mybatis-generator-maven-plugin</artifactId>
  152. <version>1.3.2</version>
  153. <configuration>
  154. <verbose>true</verbose>
  155. <overwrite>true</overwrite>
  156. </configuration>
  157. </plugin>
  158. <plugin>
  159. <groupId>org.apache.maven.plugins</groupId>
  160. <artifactId>maven-compiler-plugin</artifactId>
  161. <configuration>
  162. <source>1.7</source>
  163. <target>1.7</target>
  164. </configuration>
  165. </plugin>
  166. </plugins>
  167. </build>
  168. </project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MybatisTest</groupId>
<artifactId>MybatisTest-Demo1</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>MybatisTest-Demo1 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency> <!--mysql driver-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency> <!--spring-->
<!-- spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.5.RELEASE</version>
</dependency> <!--spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.5.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.1.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.1.RELEASE</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.1.RELEASE</version>
</dependency> <!--Spring Web + Spring MVC-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.1.RELEASE</version>
</dependency> <!--NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config-->
<!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency> <dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency> <!--servlet/jsp api start-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency> <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.2</version>
</dependency> <!--c3p0-->
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.1</version>
</dependency> <!--aspectj-->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.8.6</version>
</dependency> <dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.6</version>
</dependency> <!--jdbc-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>3.0.5.RELEASE</version>
</dependency> <!--mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.1</version>
</dependency>
<!--mybatis spring整合-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>RELEASE</version>
</dependency> <!--spring-test-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>RELEASE</version>
</dependency> </dependencies>
<build>
<finalName>MybatisTest-Demo1</finalName> <plugins>
<!--servlet容器 jetty插件-->
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.10.v20160621</version>
</plugin> <!--mybatis 逆向工程插件-->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins> </build>
</project>

3 src下面新建java包,将其设置为source root(在java包上点击右键,选择Mark Directory As Source Root),依次建如图类结构:

利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解

1)创建接口EmployeeMapper.java,这里是采用Mybatis的注解的方式,要在后面的spring-mybatis文件中去注册接口

  1. package com.mybatis.dao;
  2. import com.mybatis.model.Employee;
  3. import org.apache.ibatis.annotations.Select;
  4. import java.util.List;
  5. /**
  6. * Created by wanggenshen_sx on 2016/12/26.
  7. */
  8. public interface EmployeeMapper {
  9. @Select("select id,lastName,email from employee where id=#{id}")
  10. Employee getEmployeeById(int id);
  11. @Select("select * from employee")
  12. List<Employee> getAllEmployees();
  13. }
package com.mybatis.dao;

import com.mybatis.model.Employee;
import org.apache.ibatis.annotations.Select; import java.util.List; /**
* Created by wanggenshen_sx on 2016/12/26.
*/ public interface EmployeeMapper {
@Select("select id,lastName,email from employee where id=#{id}")
Employee getEmployeeById(int id); @Select("select * from employee")
List<Employee> getAllEmployees();
}

2)实体类:Employee.java

  1. package com.mybatis.model;
  2. /**
  3. * Created by wanggenshen_sx on 2016/12/23.
  4. */
  5. public class Employee {
  6. private int id;
  7. private String lastName;
  8. private String email;
  9. public int getId() {
  10. return id;
  11. }
  12. public void setId(int id) {
  13. this.id = id;
  14. }
  15. public String getLastName() {
  16. return lastName;
  17. }
  18. public void setLastName(String lastName) {
  19. this.lastName = lastName;
  20. }
  21. public String getEmail() {
  22. return email;
  23. }
  24. public void setEmail(String email) {
  25. this.email = email;
  26. }
  27. @Override
  28. public String toString() {
  29. return "Employee [id=" + id + ", lastName=" + lastName + ", email="
  30. + email+" ]" ;
  31. }
  32. public Employee(){}
  33. }
package com.mybatis.model;

/**
* Created by wanggenshen_sx on 2016/12/23.
*/
public class Employee { private int id;
private String lastName;
private String email; public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "Employee [id=" + id + ", lastName=" + lastName + ", email="
+ email+" ]" ;
}
public Employee(){}
}

3) Service层:

创建EmployeeService接口

  1. package com.mybatis.service;
  2. import com.mybatis.model.Employee;
  3. import java.util.List;
  4. /**
  5. * Created by wanggenshen_sx on 2016/12/26.
  6. */
  7. public interface EmployeeService {
  8. Employee getEmployee(int id);
  9. List<Employee> getEmployees();
  10. }
package com.mybatis.service;

import com.mybatis.model.Employee;

import java.util.List;

/**
* Created by wanggenshen_sx on 2016/12/26.
*/
public interface EmployeeService {
Employee getEmployee(int id); List<Employee> getEmployees();
}

创建EmployeeServiceImpl实现类:注意添加@Service注解

package com.mybatis.service;

import com.mybatis.dao.EmployeeMapper;
import com.mybatis.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import java.util.List; /**
* Created by wanggenshen_sx on 2016/12/26.
*/
@Service
public class EmployeeServiceImpl implements EmployeeService { public EmployeeServiceImpl() {
System.out.printf("init EmployeeServiceImpl");
} @Autowired
private EmployeeMapper employeeMapper; @Override
public Employee getEmployee(int id){
return employeeMapper.getEmployeeById(id);
} public List<Employee> getEmployees(){
return employeeMapper.getAllEmployees();
} }

4)在spring配置文件中整合mybatis:spring-mybatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!--自动扫描含有@Service的类,将其注入为bean -->
<context:component-scan base-package="com.mybatis.service" />
<context:component-scan base-package="com.mybatis.dao" /> <!-- 1. 数据源 : DriverManagerDataSource -->
<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mytest"/>
<property name="username" value="root"/>
<property name="password" value="920614"/>
</bean> <!--
2. mybatis的SqlSession的工厂: SqlSessionFactoryBean
dataSource / typeAliasesPackage
-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<property name="typeAliasesPackage" value="com.mybatis.model"/>
</bean> <!--
3. mybatis自动扫描加载Sql映射文件 : MapperScannerConfigurer
sqlSessionFactory / basePackage
-->
<bean id="config" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.mybatis.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean> <!-- 4. 事务管理 : DataSourceTransactionManager -->
<bean id="manager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"/>
</bean> <!-- 5. 使用声明式事务 -->
<tx:annotation-driven transaction-manager="manager" /> </beans>

建测试类:EmployeeTest.java

package com.mybatis.test;

import com.mybatis.model.Employee;
import com.mybatis.service.EmployeeService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; /**
* Created by wanggenshen_sx on 2016/12/27.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-mybatis.xml" })
public class EmployeeTest { @Autowired
private EmployeeService employeeService; @Test
public void testGetEmployeeById(){
Employee employee = employeeService.getEmployee(1);
System.out.print(employee);
} @Test
public void testGetAll(){
List<Employee> employees=employeeService.getEmployees();
System.out.print(employees);
}
}

能输出并显示数据库表的内容,即表示Spring整合Mybatis成功,接下来加入SpringMVC内容,将读取的内容显示在页面上。

4 创建springmvc-servlet.xml,配置视图信息。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"> <!--注解-->
<mvc:annotation-driven/>
<!--处理静态资源-->
<mvc:default-servlet-handler/> <!-- 自动扫描controller包下的有@Controller注解的,注入为bean -->
<context:component-scan base-package="com.mybatis.controller" /> <!--配置视图解析器-->
<bean id="viewResolverCommon" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
</bean> </beans>

5 建控制类:
EmployeeController.java

package com.mybatis.controller;

import com.mybatis.model.Employee;
import com.mybatis.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import java.util.List;
import java.util.Map; /**
* Created by wanggenshen_sx on 2016/12/26.
*/
@Controller
public class EmployeeController { @Autowired
private EmployeeService employeeService; @RequestMapping(value=",Object> map){
List<Employee> employees = employeeService.getEmployees();
/*测试用
if(employees==null)
System.out.println("null");
else
System.out.println(employees);*/ map.put("employees",employees);
return "list";
} }

6 建立显示页面: Web-app的WEB-INF下建views包下建list.jsp:

注意此处一定要加上

page false

否则无法使用jstl标签。

taglib chttp://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: wanggenshen_sx
Date: 2016/12/26
Time: 17:25
To change this template use File | Settings | File Templates.
--%>
page text/html;charset=UTF-8java" %>
page false" %>
<html>
<head>
<title>Show Page22</title>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="10">
<tr>
<th>ID</th>
<th>LastName</th>
<th>Email</th>
</tr> c="}="emp">
<tr>
<th>}</th>
<th>}</th>
<th>}</th>
</tr>
c:forEach>
</table> </body>
</html>

7 配置web.xml ,分别指定spring,springmvc配置文件的位置。注意这里一定要有四个部分,即<context-param>,<servlet>,<servlet-mapping>,<listener>.

我在这里没有添加<listener>标签,spring无法初始化,出现了【Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeController': Unsatisfied dependency expressed through field 'employeeService': No qualifying bean of type [com.mybatis.service.EmployeeService] found for dependency [com.mybatis.service.EmployeeService]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 】错误。

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-mybatis.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> <!-- 防止spring内存溢出监听器 -->
<listener>
<listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class>
</listener> <!--配置springmvc DispatcherServlet-->
<servlet>
<servlet-name>springmvc-servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:springmvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet> <servlet-mapping>
<servlet-name>springmvc-servlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

8 项目整体结构:

利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解

上一篇:Mybatis 系列8-结合源码解析select、resultMap的用法


下一篇:[Leetcode][Python]27: Remove Element