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

时间:2022-02-02 08:16:38

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项目详解

利用Intellij+MAVEN搭建Spring+Mybatis+MySql+SpringMVC项目详解的更多相关文章

  1. Maven 搭建spring boot多模块项目(附源码)&comma;亲测可以&comma;感谢原创

    原创地址:https://segmentfault.com/a/1190000005020589 我的DEMO码云地址,持续添加新功能: https://gitee.com/itbase/Spring ...

  2. Maven 搭建spring boot多模块项目

    Maven 搭建spring boot多模块项目 备注:所有项目都在idea中创建 1.idea创建maven项目 1-1: 删除src,target目录,只保留pom.xml 1-2: 根目录pom ...

  3. springmvc学习总结(二) -- maven&plus;springmvc&plus;spring&plus;mybatis&plus;mysql详细搭建整合过程讲解

    @_@ 写在最前 之前分享过下面这几篇: mybatis学习笔记(五) -- maven+spring+mybatis从零开始搭建整合详细过程(上)(附demo和搭建过程遇到的问题解决方法) myba ...

  4. maven&plus;springmvc&plus;spring&plus;mybatis&plus;mysql详细搭建整合过程讲解

    转自:https://www.cnblogs.com/lmei/p/7190755.html?utm_source=itdadao&utm_medium=referral @_@ 写在最前 之 ...

  5. freemarker &plus; spring mvc &plus; spring &plus; mybatis &plus; mysql &plus; maven项目搭建

    今天说说搭建项目,使用freemarker + spring mvc + spring + mybatis + mysql + maven搭建web项目. 先假设您已经配置好eclipse的maven ...

  6. SpringMVC&plus;Spring&plus;Mybatis&plus;Mysql项目搭建

    眼下俺在搭建一个自己的个人站点玩玩.一边练习.一边把用到的技术总结一下,日后好复习. 站点框架大致例如以下图所看到的: 眼下仅仅用到了SpringMVC+Spring+Mybatis+Mysql.把它 ...

  7. SpringMVC&plus;Spring&plus;mybatis项目从零开始--Spring mybatis mysql配置实现

    上一章我们把SSM项目结构已搭建(SSM框架web项目从零开始--分布式项目结构搭建)完毕,本章将实现Spring,mybatis,mysql等相关配置. 1.    外部架包依赖引入 外部依赖包引入 ...

  8. Spring MVC&plus;Spring&plus;Mybatis&plus;MySQL&lpar;IDEA&rpar;入门框架搭建

    目录 Spring MVC+Spring+Mybatis+MySQL(IDEA)入门框架搭建 0.项目准备 1.数据持久层Mybatis+MySQL 1.1 MySQL数据准备 1.2 Mybatis ...

  9. SpringMVC &plus;Spring &plus; MyBatis &plus; Mysql &plus; Redis&lpar;作为二级缓存&rpar; 配置

    转载:http://blog.csdn.net/xiadi934/article/details/50786293 项目环境: 在SpringMVC +Spring + MyBatis + MySQL ...

随机推荐

  1. sys&period;dm&lowbar;tran&lowbar;locks,

    sys.dm_tran_locks 返回有关当前活动的锁管理器资源的信息.向锁管理器发出的已授予锁或正等待授予锁的每个当前活动请求分别对应一行. 列名 数据类型 说明 resource_type nv ...

  2. shell test 數值 字符串 文件比較

    數值比較 描述 n1 –eq n2 等於 n1 –gt  n2 大於 n1 –ge n2 大於等於 n1 –lt  n2 小於 n1 –le n2 小於等於 n1 –ne n2 不等於   字符串比較 ...

  3. 解读HTML 5新语法 提高语义价值

    HTML 5的新标记 设计者们需要完成的任务是要给HTML 5开发一个更丰富的和更有含义的语义,当然可以想象这种新方案将会是很灵活和很高效的,同时与所有的现代互联网标准相适应.下面就是一些将要在HTM ...

  4. wpf 自定义窗口,最大化时不覆盖任务栏

    相信很多人使用wpf时会选择自定义美观的窗口,因此会设置WindowStyle="None" 取消自带的标题栏.但这样使用 WindowState="Maximized& ...

  5. Qt 窗口属性简介之Qt&colon;&colon;WA&lowbar;DeleteOnClose

    一.简述 今天介绍一个简单的窗口属性——Qt::WA_DeleteOnClose. 在正常创建窗口后,我们一般会调用close()方法来关闭窗口,这里我们看一下Q助手中关于close()方法的介绍. ...

  6. 原创新闻 11 个最佳 jQuery 滚动条插件

    通过jQuery滚动条插件,你可以换掉千篇一律的默认浏览器滚动条,让你的网站或web项目更具特色,更有吸引力.本文收集了11款非常漂亮.实用的jQuery滚动条插件,你可以轻松将它们应用在自己的网站中 ...

  7. 常用命令su ls cp cd mv cat touch mkdir rm head less more pwd tac 等

    1.用户切换 su:switch user su kevin   //半切换,切换到kevin用户,但是不读取kevin用户的配置文件 su - kevin   //完全切换,执行这个命令的时候表示切 ...

  8. 设置文件opendilag、savedilog默认路径和文件类型

    dlgSave1.Filter:='文件.txt|*.txt;|word文件|*.doc,*.docx'; dlgSave1.InitialDir:=GetCurrentDir; //设置为当前路径 ...

  9. 通过SID查找历史执行的SQL语句

    这次某系统发生严重的阻塞,但是去查*会话,发现已经没有该对应的sql_id了,于是我们只用通过 v$active_session_history 视图来寻找.下面是查找的过程: 1.查找顶层ASH历 ...

  10. 基于vue-cli3&period;0构建功能完善的移动端架子,主要功能包括

    webpack 打包扩展 css:sass支持.normalize.css._mixin.scss._variables.scss vw.rem布局 跨域设置 eslint设置 cdn引入 路由设计. ...