当前位置: 首页 > news >正文

SpringMvc+Spring+MyBatis+Maven+Ajax+Json注解开发 利用Maven的依赖导入不使用架包模式 (实操十)

采用的的技术如下图所示

本文章的目标实现二个内容:

第一个任务完成:如何完成在Maven项目中的SSM环境搭建?

第二个任务完成:如何建立起自己的数据库建立起自己的数据库中表的数据?

采用的技术有:开发工具IDEA SpringMvc Spring MyBatis Maven Ajax Json 前端的Html Css Jquery 注解的方式开发

提出自己的问题?

如何查序淘宝订单管理系统的所有信息

分析数据库的表中的信息?

1 在数据库的表中什么是字段?

答:在表中的一个个的单元格,称为字段通俗来讲 如果将一个个的单元格当成一个点的话 二维直角坐标X Y 轴的交点

2 在数据库的表中什么是记录?

答:一条记录中有多个单元格 多个字段

3 如果查序的是一条记录多个字段的时 在Java中利用什么方式存放起来呢?

答:Map 集合来存  <Map<String, String>> map = service.getList();

4 如果查序的是多条记录在一条记录中多个字段的时 在Java中利用什么方式存放起来呢?

答:List中套用Map集合 List<Map<String, String>> list = service.getList();

在构建maven项目的时候我们要在Pom.xml文件中导入以下依赖坐标

官网:https://mvnrepository.com/artifact/com.networknt/service/2.1.1

1 Spring框架

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.3.23</version>
</dependency>

2 Spring Web 框架的依赖

<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.3.23</version>
</dependency>

3 MyBatis 框架的依赖

<!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.10</version>
</dependency>

4 Jquery的依赖

<!-- https://mvnrepository.com/artifact/org.webjars.bower/jquery -->
<dependency>
    <groupId>org.webjars.bower</groupId>
    <artifactId>jquery</artifactId>
    <version>3.6.1</version>
</dependency>

5 Junit的依赖

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.13.2</version>
    <scope>test</scope>
</dependency>

6 Service的依赖

<!-- https://mvnrepository.com/artifact/com.networknt/service -->
<dependency>
    <groupId>com.networknt</groupId>
    <artifactId>service</artifactId>
    <version>2.1.1</version>
</dependency>

7 druid-1.1.20的依赖

<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.2.12</version>
</dependency>

上面的7步导入依赖等价于上个学期的架包的方式:

官网:https://mvnrepository.com/artifact/com.networknt/service/2.1.1

在resources文件中开始配置三个框架的配置文件信息 在后面学习了SpringBoot配置文件可能省略

下面配置文件是 applicationContext.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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	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.xsd
			    http://www.springframework.org/schema/aop
			    http://www.springframework.org/schema/aop/spring-aop.xsd
			    http://www.springframework.org/schema/tx
			    http://www.springframework.org/schema/tx/spring-tx.xsd">

	<!--开启组件扫描 -->
	<context:component-scan
		base-package="Com.Orders.Service" />
	<!-- 引入外面的properties常量配置文件 -->
	<context:property-placeholder
		location="classpath:db.properties" />
	<!-- 数据源配置 -->
	<bean id="dataSource"
		class="com.alibaba.druid.pool.DruidDataSource">
		<property name="driverClassName" value="${jdbc.driver}" />
		<property name="url" value="${jdbc.url}" />
		<property name="username" value="${jdbc.username}" />
		<property name="password" value="${jdbc.password}" />
	</bean>
	<!-- 事务管理器 -->
	<bean id="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
	<!-- 开启基于注解配置的事务管理 -->
	<tx:annotation-driven
		transaction-manager="transactionManager" />

	<!-- 扫描mapper接口文件 -->
	<bean id="mapperScannerConfigurer"
		class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="Com.Orders.Dao" />
	</bean>

	<!-- 创建sqlSession工厂 -->
	<bean id="sessionFactory"
		class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<!-- <property name="typeAliasesPackage" value="com.yhh.domain" /> -->
		<!-- 如果还有一些专门针对于mybatis的配置,需要引入 -->
		<property name="configLocation"
			value="classpath:mybatis-config.xml" />

		<!--  配置mybatis分页插件PageHelper -->
		<property name="plugins">
			<array>
				<bean class="com.github.pagehelper.PageInterceptor">
					<property name="properties">
						<value></value>
					</property>
				</bean>
			</array>
		</property>
	</bean>
</beans>

下面的文件是 SpringMvc框架的配置信息

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	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.xsd
			    http://www.springframework.org/schema/aop
			    http://www.springframework.org/schema/aop/spring-aop.xsd
			    http://www.springframework.org/schema/tx
			    http://www.springframework.org/schema/tx/spring-tx.xsd
			    http://www.springframework.org/schema/mvc
			    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<!--开启组件扫描 -->
	<context:component-scan
		base-package="Com.Orders.Controller" />

	<!--开启mvc注解支持 -->
	<mvc:annotation-driven />

	<!--释放静态资源 -->
	<mvc:default-servlet-handler />

	
</beans>

下面的文件是 MyBatis框架配置文件信息

<?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:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	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.xsd
			    http://www.springframework.org/schema/aop
			    http://www.springframework.org/schema/aop/spring-aop.xsd
			    http://www.springframework.org/schema/tx
			    http://www.springframework.org/schema/tx/spring-tx.xsd
			    http://www.springframework.org/schema/mvc
			    http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<!--开启组件扫描 -->
	<context:component-scan
		base-package="Com.Orders.Controller" />

	<!--开启mvc注解支持 -->
	<mvc:annotation-driven />

	<!--释放静态资源 -->
	<mvc:default-servlet-handler />

	
</beans>
SSM三层的架构信息

第一个任务完成:上面完成在Maven项目中的SSM环境搭建

第二个任务完成:建立起自己的数据库建立起自己的数据库中表的数据

ROP TABLE IF EXISTS `orders`;
CREATE TABLE `orders`  (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '订单编号',
  `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '用户名称',
  `foondname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '商品名称',
  `ordertime` varchar(22) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '订单时间',
  `count` int NOT NULL COMMENT '数量',
  `price` double(10, 2) NOT NULL COMMENT '商品价格',
  `amount` double(255, 2) NOT NULL COMMENT '金额',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 10 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
INSERT INTO `orders` VALUES (1, '笔记本', 'Deal', '2022.8.12', 3456, 1234.00, 3459.00);
INSERT INTO `orders` VALUES (2, '书本', '人生的意义', '2022.3.24', 2345, 4566.00, 1234.00);
INSERT INTO `orders` VALUES (3, '手机', 'HuWei', '2022.3.21', 4567, 45678.00, 2345.00);
INSERT INTO `orders` VALUES (4, '漫画书', '三毛', '2022.1.4', 6789, 3245.00, 1234.00);
INSERT INTO `orders` VALUES (5, '电视机', '电信', '2022.3.4', 9087, 4532.00, 2346.00);
INSERT INTO `orders` VALUES (6, '电脑', '华为', '2022.6.7', 34566, 3452.00, 1234.00);

 上面是原创图片禁止下载:

相关文章:

  • 编程中什么情况下需要加 volatile?
  • 机器学习数据集读取和预处理
  • 两万字带你了解Java多线程(详细大总结)
  • 转行自学软件测试没后悔,我的经历证明,改变永远没有错
  • Pandas数据分析:快速图表可视化各类操作详解+实例代码(一)
  • mysql的主从创建及mycat的安装
  • OSS存储开放接口规范 和 错误响应
  • 悲观锁、乐观锁和自旋锁
  • RTL8720CM WI-FI+蓝牙,低功耗IoT(物联网)应用 40QFN
  • 程序设计竞赛-过了这个村没这个店
  • C语言实现基于高效率IP路由查找的内容
  • 南大通用GBase8s 常用SQL语句(263)
  • Bootstrap Table 实现 分页选中
  • 嵌入式系统开发笔记89:认识AVR微控制器系统架构
  • GeoPandas安装
  • SegmentFault for Android 3.0 发布
  • 【node学习】协程
  • Android开发 - 掌握ConstraintLayout(四)创建基本约束
  • echarts的各种常用效果展示
  • exif信息对照
  • iOS 系统授权开发
  • javascript 哈希表
  • Redis学习笔记 - pipline(流水线、管道)
  • sublime配置文件
  • supervisor 永不挂掉的进程 安装以及使用
  • WinRAR存在严重的安全漏洞影响5亿用户
  • 快速体验 Sentinel 集群限流功能,只需简单几步
  • 前端面试之闭包
  • 深度学习入门:10门免费线上课程推荐
  • 问:在指定的JSON数据中(最外层是数组)根据指定条件拿到匹配到的结果
  • 我看到的前端
  • Java总结 - String - 这篇请使劲喷我
  • ​io --- 处理流的核心工具​
  • ​虚拟化系列介绍(十)
  • #### golang中【堆】的使用及底层 ####
  • $.each()与$(selector).each()
  • (12)Hive调优——count distinct去重优化
  • (CPU/GPU)粒子继承贴图颜色发射
  • (ISPRS,2021)具有遥感知识图谱的鲁棒深度对齐网络用于零样本和广义零样本遥感图像场景分类
  • (二)原生js案例之数码时钟计时
  • (机器学习-深度学习快速入门)第一章第一节:Python环境和数据分析
  • (生成器)yield与(迭代器)generator
  • (十八)SpringBoot之发送QQ邮件
  • (一)80c52学习之旅-起始篇
  • (转)【Hibernate总结系列】使用举例
  • (转)母版页和相对路径
  • (自用)仿写程序
  • .bat批处理出现中文乱码的情况
  • .NET Core SkiaSharp 替代 System.Drawing.Common 的一些用法
  • .NET Core使用NPOI导出复杂,美观的Excel详解
  • .NET 常见的偏门问题
  • .net 桌面开发 运行一阵子就自动关闭_聊城旋转门家用价格大约是多少,全自动旋转门,期待合作...
  • .pop ----remove 删除
  • @CacheInvalidate(name = “xxx“, key = “#results.![a+b]“,multi = true)是什么意思
  • @kafkalistener消费不到消息_消息队列对战之RabbitMq 大战 kafka