Web后端模板引擎的研究与应用基于MyBatis-Plus外文翻译资料

 2022-08-21 23:29:55

3rd International Conference on Mechatronics and Intelligent Robotics (ICMIR-2019)

Research and Application of Template Engine for Web Back-end Based on MyBatis-Plus

Yao Zhang Li1 , Sheng Gao1,* , Jing Pan2, Bi Feng Guo1, Pei Feng Xie*1*

1Faculty of Mathematics and Computer Science, Guangdong Ocean University

2Faculty of Management, Guangdong Ocean University

Abstract

In web development, it takes much time to code for back-end including business logic and interface integration, which is machanized and high-repeated. In order to address the problem in back-end web coding, this paper analyzes the advantages and disadvantages of SSM(Spring, SpringMVC and MyBatis) framework and development pattern of the original and end separation. By integrating the template engine in PHP web development, we achieve the technology of code generation for back-end of web, which benefits for artificial intelligence of web coding and saves the time on software engineering.

copy; 2020 The Authors. Published by Elsevier B.V.

This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/)

Peer-review under responsibility of the scientifi committee of the 3rd International Conference on Mechatronics and Intelligent Robotics, ICMIR-2019.

Keywords Back-end Development ; Code Generation ; Template Engine

Introduction

1.1 Background of Software and Web

With the development of information technology, the use of software crowds into peoples life including in entertainment and office work. Differing from hardware, software is made of a series of computer data and instruction list[1]. Software is not only the program in the computer, files are also the parts of software. Software includes operating software and application software. As we know, android and ios operating system are the popular operating software. Web is a kind of application software existing in the operating software.

* Corresponding Author. Tel. (86) 13924401222

*E-mail: minix@139.com

1877-0509 copy; 2020 The Authors. Published by Elsevier B.V.

This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/)

Peer-review under responsibility of the scientific committee of the 3rd International Conference on Mechatronics and Intelligent Robotics, ICMIR-2019.

10.1016/j.procs.2020.02.052

1.2 Literature Review

Application development, program development, phone application development[2] and web development[3] are included in software development. This paper introduces the development of web service(which is called back-end development) based on the Java Web. In the development of the web, design patterns include MVC(Model, View and Controller) pattern, Web Form, Web Page and so on, but the most popular pattern used by developers is MVC pattern[4]. Some scholars think that MVC pattern has the advantage of low coupling and the data in this project is highly uniform[5]. However, others think that it makes the coding redundant and the assessed data inefficient[6]. Based on the MVC pattern, the development pattern is a kind of pattern with the separation of front-end and back- end. Using this pattern[7], the professionals will be responsible for the different parts of web development and the development is divided into front-end and back-end interacted with interfaces[8]. At present, the most popular technical framework is SSM(Spring, SpringMVC and MyBatis)[9-11] framework and it is widely used in last few years. Differing from SSH(Spring, Struts and Hibernate) framework, it handles requests and responses better and is suitable for RESTful coding style and MVC pattern[12]. Nevertheless, this development pattern has a disadvantage that the interfaces for each Model have the same functional interface, causing so many high-repeated codes in the project and it wastes the developers much time. In the development of PHP[13], this problem is handled by Template Engine. Because of the differences between Java and PHP, less Java developers generate codes with template engine[14]. This technology does deal with the problem effectively.

Operation Mechanism of Web Development

    1. MVC Pattern

MVC Pattern is an interactive interface structure design pattern presented in the 1980s and it is also an effective design pattern. The MVC design pattern emphasizes that developers design their software in a modular fashion based on usersrsquo; input, data model and information display. It divides an application software into the following three parts.

Model is the business logic of application software including date and model. Model is the core functionality of the application and it encapsulates the data and problem solving process. User calls the Model by calling Controller so that the Model can provide data for Views to reduce the code redundancy.

View is the part of the application software that handles the display of data, which displays different information. View is an interface seen and interacted by users. For the View, data and problem soling process are ignored, from which users can send service requests to the Model by calling the Controller to update the View.

Controller is the part of the application software which handles interactions. Controller converts the inputted information such as mouse and keyboard into service request for Model and View, and it responses the changes of Model to the View. And users only interact with software by Controller.

One set of View and Controllers make up a user interface and a Model can h

剩余内容已隐藏,支付完成后下载完整资料


第三届机电一体化与智能机器人国际会议(ICMIR-2019)

Web后端模板引擎的研究与应用基于MyBatis-Plus

Yao Zhang Li1 , Sheng Gao1,* , Jing Pan2, Bi Feng Guo1, Pei Feng Xie*1*

1广东海洋大学数学与计算机科学学院

2广东海洋大学管理学院

摘要

在web开发中,为后端(包括业务逻辑和接口集成)编写代码可能需要程序员花费大量时间machanized和高重复。为了解决后端web编码的问题,本文分析了后端web编码的优点以及不足的地方。SSM(Spring、SpringMVC和MyBatis)框架的缺点和开发模式的原端分离。通过将模板引擎集成到PHP web开发中,实现了web后台的代码生成技术,这既有利于网络编码的人工智能,又节省了软件工程的时间。

copy;2020作者。由爱思唯尔出版

这是一篇CC BY-NC-ND许可下的开放获取文章(http: // creativecommons. org/ licenses/ bync –nd / 4.0/)由第三届机电一体化与智能国际会议科学委员会负责的同行评审。机器人技术,icmir - 2019。

关键词 后端开发;代码生成;模板引擎

第1章 介绍

1.1 软件和Web背景

随着信息技术的发展,软件的使用越来越多地进入人们的生活娱乐和办公室工作。但是与硬件不同,软件是由一系列的计算机数据和指令表[1]。软件不仅是计算机中的程序,文件也是软件的组成部分。软件包括操作软件和应用软件。众所周知,android和ios操作系统是最受欢迎也是最常用的操作软件。并且Web是存在于操作软件中的一种应用软件。

*通讯作者。电话。 (86)13924401222

*电子邮件:minix@139.com

作者:1877-0509copy;2020由爱思唯尔出版

这是一篇CC BY-NC-ND许可下的开放访问文章(http: // creativecommons. org/ licenses/ bync –nd / 4.0/)由第三届机电一体化与智能机器人国际会议科学委员会负责的同行评审,icmir - 2019。10.1016 / j.procs.2020.02.052

1.2 文献综述

应用程序开发、程序开发、电话应用程序开发[2]和web开发[3]包括在软件开发中。本文将会介绍了web服务(称为后端)的开发开发)基于Java Web。在web开发中,设计模式包括MVC(Model, View)模式、Web表单、Web页面等等,但是开发人员最常用的模式是MVC模式[4]。有学者认为MVC模式具有低耦合的优点,本项目的数据也是如此高度统一的[5]。然而,其他人认为它使编码冗余和评估的数据效率低下的[6]。基于MVC模式的开发模式是一种前端与后端的分离模式。使用此模式[7],专业人员将负责web开发的不同部分开发分为与接口[8]交互的前端和后端。目前,最受欢迎的技术框架是SSM(Spring, SpringMVC和MyBatis)[9-11]框架并且在后几个版本中得到了广泛的应用,在最后的几年里面。与SSH(Spring、Struts和Hibernate)框架不同,它可以更好地处理请求和响应,适合RESTful编码风格和MVC模式的[12]。尽管如此,这种发展模式有一个缺点是它的每个模型的接口都具有相同的功能接口,从而导致了如此多的高重复码并且它十分的浪费了了开发人员大量的时间使得工作效率变得低。在PHP[13]的开发中,这个问题主要是由模板引擎产生的。由于Java和PHP之间的差异,很少有Java开发人员使用模板引擎[14]。所以这项技术确实有效地解决了这个问题。

第2章 Web开发的操作机制

2.1 MVC模式

MVC模式是在20世纪80年代出现的一种交互界面结构设计模式,也是一种有效的交互界面结构设计模式。MVC设计模式强调开发人员以模块化的方式设计他们的软件基于用户的输入、数据模型和信息显示。

它将一个应用软件分为以下三个部分:

第一部分:模型(model)是应用软件的业务逻辑,包括日期和模型。模型是其核心功能该应用程序封装了数据和问题解决过程。用户通过调用控制器来调用模型,这样模型就可以为视图提供数据来减少代码冗余。

第二部分:视图(view)是应用软件中处理数据显示的部分,数据显示不同的信息。视图是用户看到并交互的界面。对于视图,忽略数据和问题解决过程中哪些用户可以通过调用控制器来更新视图来向模型发送服务请求。

第三部分:控制器(controller)是应用软件中处理交互的部分。控制器转换输入信息如鼠标和键盘进入服务请求模型和视图,它响应的变化模型到视图。用户只能通过控制器与软件进行交互。

一组视图和控制器组成一个用户界面,一个模型可以有多个视图。如果用户更改通过控制器建模,控制器将这种变化扩展到所有视图,从而使得实现显示的统一。

2.2端部分离的发展模式

Web页面是早期的设计模式之一,它要求开发人员熟练掌握整个开发的过程。它还让开发人员了解关于web开发的所有技术,从而产生模棱两可的结果,所以加重了开发人员的职责。因此,开发人员需要熟练掌握web项目中混乱的代码是一件不是很容易上手的事情。

所以显而易见的可以看出,MVC模式真的在程序中改变了很多方面。其中它最明显的改进的地方应该是是端分离开发模式。这就意味着项目开发主要分为两个部分:第一个是前端开发,第二个是后端开发。

在这种开发模式中,前端工程师则应该更加注重页面表达、用户体验、兼容性等以及后端工程师更关心高性能、安全性和业务逻辑。显而易见的是,与原始的开发模式如Web表单和Web页面相比,这样的开发模式并没有减少对开发人员的技术要求,而是提高了对开发人员标准,所以对于技术方面并没有减轻反而提高了开发人员的标准问题。

2.3 SSM框架

Spring是一个开源java框架。它是一个为降低企业复杂性从而开发的框架项目开发。Spring的核心功能是IOC(控制反转)和AOP(面向方面的)编程)。由于这两个核心功能,几乎任何Java应用程序都可以从中受益。Spring是一个轻量级、低介入的开放源码框架,使它与其他框架可以做到互相的兼容。

SpringMVC是Spring的一个子项目,具有与Spring相同的低侵入性特性的特征。这是一个框架可以使得后端开发和前端开发是完全分离的。所以也就是说,几乎可以使用任何的视图。此外,Spring使java web组件在SpringMVC中得到更好的管理和兼容。

Mybatis是Apache的一个开源项目iBatis,它后来被迁移到谷歌代码并且重新命名为MyBatis。MyBatis它封装了几乎所有的JDBC操作,并扩展了参数设置和的功能返回结果集。它让数据库底层操作变的透明。mybatis的操作都是围绕一个sqlSessionFactory实例展开的。mybatis通过配置文件关联到各实体类的Mapper文件,Mapper文件中配置了每个类对数据库所需进行的sql语句映射。在每次与数据库交互时,通过sqlSessionFactory拿到一个sqlSession,再执行sql命令。通过解析配置文件和相应的映射文件,实现原来的JDBC功能进行了扩展,使应用程序以及数据库之间可以进行简单的交互。如图2-1工作模式图所示SSM的工作模式图:

图2-1 SSM工作模式图

当我们使用SSM框架,其中后端开发主要被分为三层。它们主要是层控制器,层服务和层DAO。层控制器用于处理相关请求,调用相关服务完成业务逻辑并选择相应的视图作为对用户的反馈。服务层封装业务逻辑,调用层Dao并对异常进行预处理。MyBatis集成层服务操作数据库作为层DAO,并且可以持久化数据。

2.4问题分析

一般来说,SSM框架的后端开发过程主要是是数据库设计、实体类设计、层设计DAO开发,层服务开发,层控制器开发,与前端集成项目完成。即使是这样的情况下,虽然前端和后端之间的耦合减少了,即使它的代码可维护性高。但它仍存在以下问题。

高重复性的代码。在这种开发模式中,数据库中几乎每个表的操作都有CRUD(创建、检索、更新和删除)。无论层DAO、层服务还是层控制器都会代码重复性高。而且,作为底层开发的后端,其开发周期较长这个阶段的时间不能缩短。这种开发使开发人员忙于编码,而不是花更多的时间考虑复杂的业务逻辑。

项目开发周期长。对于企业项目,数据库中可能有数百甚至数千张的表,都是不确定性的。所以它开发CRUD需要很长的时间,这将延迟业务逻辑的开发,结果会造成较大的周期项目的开发。所以这种问题需要立即解决,要不然对项目的时间和人力物力方面都会造成比较大的损失。所以接下来,是针对此问题,来进行方法的研究,并拿出相应的解决方案。

第3章 研究方法与解决方案

3.1研究方法

有了上面的这些问题,可以不难发现这样的代码编写其实是相对比较简单的。但就是有点机械的劳动。所以主要的解决此类方案是进行缩短简单CRUD的代码开发周期以及改进编码的效率。同样的问题,另一种编程语言PHP,就会有一个非常有效的解决方案,那就是模板引擎。Java也使用了相应的技术。在于两种语言的差异,但这不是Java的常规开发方法。

3.2案例分析

因为PHP的模板引擎与Java使用的模板引擎不同,所以这里漏掉了PHP模板引擎。Java的模板引擎主要用于JSP (Java服务器页面)。 目前只有两种流行模板引擎:FreeMaker以及Velocity。这两个模板引擎的编程语言是相对比较的简单。

在考虑了相关引擎的框架之后,我们找到了一个名为MyBatis-Plus的开源框架。这个框架是对MyBatis进行了一个有效的增强,它改进了MyBatis的功能,但是并没有改变MyBatis的原始结构。通过该框架的扩展功能,我们可以生成层的代码通过模板引擎实现DAO、层服务以及层控制器。

3.3情况下重构

最重要的是,这是一个开源的框架。许多人共享框架的用例官方文件都是在官方网站上。我们需要做的是编写启动类和模板。如下列代码是控制器层模板的主要代码的展现:

@Postmapping
public ResultDTO insert One($ entity) sitable. entityPath))throws Exception{

Sitable. entityPath) Service. save($itable. EntityPath;
return ResultUtil Success($itable. entityPath);

}
@PutMapping
public ResultDTO updateById(s entity) $itable. entityPath))throws Exception{

sitable entity Path) Service. updateById(sitable. entityPath));
return ResultUtil Successo;

}
@DeleteMapping('/[id: \d )
public Resultdto deleteBy Id(ePathvariable Long id throws Exception {

$[table. entityPath) Service. removeById((long) id);
return ResultUtil Succes();

}
@GetMapping('/page')
public IPagelt;$ entity)gt; selectEntityPage($ entity) ${table. entityPath){

@RequestParam(value =”pageNum”, defaultvalue =”1”)int pageNum;
@RequestParam(value =”pageSize”, defaultvalue =”8”)int pageSize)throws Exception;
QueryWrapperlt;$ tentity)gt;$itable. entity Path) QueryWrapper new QueryWrapperlt;gt;();
return ${itable. entityPath}Service. page (new Pagelt;$ entity)gt;(pageNum, pageSize), ${table.

entity Path} QueryWrapperlt;gt;();

}

@GetMapping('/list')
public ResultDTo selec

剩余内容已隐藏,支付完成后下载完整资料


资料编号:[409645],资料为PDF文档或Word文档,PDF文档可免费转换为Word

原文和译文剩余内容已隐藏,您需要先支付 30元 才能查看原文和译文全部内容!立即支付

以上是毕业论文外文翻译,课题毕业论文、任务书、文献综述、开题报告、程序设计、图纸设计等资料可联系客服协助查找。