SSM实现CRUD

本是古典 何须时尚 2022-11-04 01:53 252阅读 0赞

项目概况:

完成一个SSM项目的增删改查
基础框架:SSM SpringMVC+Spring+Mybatis
前端框架:Bootstrap快速搭建简介美观的页面
项目依赖管理:Maven
分页插件:pagehelper
逆向工程:Mybatis-Generator
数据库:MySQL 5.7
开发软件及环境:eclipse JDK 1.8 Tomcat 8.0

项目展示

在这里插入图片描述

1. 创建一个maven工程

搭建maven
eclipse创建maven工程

2 .引入项目所依赖的Jar包

spring springmvc mybatis 数据库连接池 驱动包 其他(jstl servlet-api, junit 等jar包)
pom.xml文件

  1. <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/xsd/maven-4.0.0.xsd">
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>SSM-CRUD</groupId>
  4. <artifactId>SSMCRUD</artifactId>
  5. <version>0.0.1-SNAPSHOT</version>
  6. <packaging>war</packaging>
  7. <!-- 引入项目以来的包 -->
  8. <!-- 引入springmvc spring-->
  9. <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
  10. <dependencies>
  11. <!--引入pageHelper分页插件 -->
  12. <dependency>
  13. <groupId>com.github.pagehelper</groupId>
  14. <artifactId>pagehelper</artifactId>
  15. <version>5.0.0</version>
  16. </dependency>
  17. <!-- MBG -->
  18. <!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
  19. <dependency>
  20. <groupId>org.mybatis.generator</groupId>
  21. <artifactId>mybatis-generator-core</artifactId>
  22. <version>1.3.5</version>
  23. </dependency>
  24. <dependency>
  25. <groupId>org.springframework</groupId>
  26. <artifactId>spring-webmvc</artifactId>
  27. <version>4.3.7.RELEASE</version>
  28. </dependency>
  29. <!-- 返回json字符串的支持 -->
  30. <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
  31. <dependency>
  32. <groupId>com.fasterxml.jackson.core</groupId>
  33. <artifactId>jackson-databind</artifactId>
  34. <version>2.8.8</version>
  35. </dependency>
  36. <!--JSR303数据校验支持;tomcat7及以上的服务器, tomcat7以下的服务器:el表达式。额外给服务器的lib包中替换新的标准的el -->
  37. <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator -->
  38. <dependency>
  39. <groupId>org.hibernate</groupId>
  40. <artifactId>hibernate-validator</artifactId>
  41. <version>5.4.1.Final</version>
  42. </dependency>
  43. <!-- Spring-Jdbc -->
  44. <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
  45. <dependency>
  46. <groupId>org.springframework</groupId>
  47. <artifactId>spring-jdbc</artifactId>
  48. <version>4.3.7.RELEASE</version>
  49. </dependency>
  50. <!--Spring-test -->
  51. <!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
  52. <dependency>
  53. <groupId>org.springframework</groupId>
  54. <artifactId>spring-test</artifactId>
  55. <version>4.3.7.RELEASE</version>
  56. </dependency>
  57. <!-- Spring面向切面编程 -->
  58. <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
  59. <dependency>
  60. <groupId>org.springframework</groupId>
  61. <artifactId>spring-aspects</artifactId>
  62. <version>4.3.7.RELEASE</version>
  63. </dependency>
  64. <!--MyBatis -->
  65. <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
  66. <dependency>
  67. <groupId>org.mybatis</groupId>
  68. <artifactId>mybatis</artifactId>
  69. <version>3.4.2</version>
  70. </dependency>
  71. <!-- MyBatis整合Spring的适配包 -->
  72. <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
  73. <dependency>
  74. <groupId>org.mybatis</groupId>
  75. <artifactId>mybatis-spring</artifactId>
  76. <version>1.3.1</version>
  77. </dependency>
  78. <!-- 数据库连接池、驱动 -->
  79. <!-- https://mvnrepository.com/artifact/c3p0/c3p0 -->
  80. <dependency>
  81. <groupId>c3p0</groupId>
  82. <artifactId>c3p0</artifactId>
  83. <version>0.9.1</version>
  84. </dependency>
  85. <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  86. <dependency>
  87. <groupId>mysql</groupId>
  88. <artifactId>mysql-connector-java</artifactId>
  89. <version>5.1.41</version>
  90. </dependency>
  91. <!-- (jstl,servlet-api,junit) -->
  92. <!-- https://mvnrepository.com/artifact/jstl/jstl -->
  93. <dependency>
  94. <groupId>jstl</groupId>
  95. <artifactId>jstl</artifactId>
  96. <version>1.2</version>
  97. </dependency>
  98. <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
  99. <dependency>
  100. <groupId>javax.servlet</groupId>
  101. <artifactId>javax.servlet-api</artifactId>
  102. <version>3.0.1</version>
  103. <scope>provided</scope>
  104. </dependency>
  105. <!-- junit测试 -->
  106. <!-- https://mvnrepository.com/artifact/junit/junit -->
  107. <dependency>
  108. <groupId>junit</groupId>
  109. <artifactId>junit</artifactId>
  110. <version>4.12</version>
  111. </dependency>
  112. <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
  113. <!-- 返回json字符串 -->
  114. <dependency>
  115. <groupId>com.fasterxml.jackson.core</groupId>
  116. <artifactId>jackson-databind</artifactId>
  117. <version>2.8.8</version>
  118. </dependency>
  119. </dependencies>
  120. </project>

3.引入Bootstrap 前端框架

BootStrap的CSS样式设计

4.编写SSM整合的关键配置文件

web.xml spring springmvc mybatis
在这里插入图片描述

5.配置SpringMVC

6.mybatis的逆向工程生成对应的bean以及mapper

7.mapper测试

8.CURD之Spring单元测试查询数据并测试

9.搭建BootStrap分页页面并查询数据

10.ajax获取JSON字符串数据并添加信息状态码提示

发表评论

表情:
评论列表 (有 0 条评论,252人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ssm crud

    阅读前提:有一定的基础,这篇提供给新手人员学习参考,希望对你有帮助。 ssm的crud,最终结果如下,虽然结果对于外行人看起来很简单,但实际对于内行人却需要写大量的代码。这里