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

大连h5建站做网站怎么优化

大连h5建站,做网站怎么优化,客服网站,国内伪娘做网站1、MyBatis-Plus概述 MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 【技术储备】 拥有 Java 开发环境以及相应 IDE…

1、MyBatis-Plus概述

MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis (opens new window)的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。

【技术储备】

拥有 Java 开发环境以及相应 IDE

熟悉 Spring Boot

熟悉 Maven

【特征】

为简化开发而生

1、只做增强不做改变,引入它不会对现有工程产生影响,如丝般顺滑。

2、效率至上:只需简单配置,即可快速进行单表 CRUD 操作,从而节省大量时间。

3、丰富功能:代码生成、自动分页、逻辑删除、自动填充等功能一应俱全。

2、数据库支持

任何能使用 MyBatis 进行 CRUD, 并且支持标准 SQL 的数据库,具体支持情况如下,如果不在下列表查看分页部分教程 PR 您的支持。

MySQL,Oracle,DB2,H2,HSQL,SQLite,PostgreSQL,SQLServer,Phoenix,Gauss ,ClickHouse,Sybase,OceanBase,Firebird,Cubrid,Goldilocks,csiidb,informix,TDengine,redshift

达梦数据库,虚谷数据库,人大金仓数据库,南大通用(华库)数据库,南大通用数据库,神通数据库,瀚高数据库,优炫数据库,星瑞格数据库

3、快速上手案例

版本信息:springboot2.7.14+mysql5.1.42+mybatis-plus3.5.3.2

【工程结构】

3.1、创建springboot工程被导入相关依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.3.2</version>
</dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.42</version>
</dependency>
<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional>
</dependency>

3.2、配置数据库相关信息

log-impl控制台打印出mybatis执行时的具体sql、查询条件、返回值等

map-underscore-to-camel-casemybatisplus在查询数据库的时候回默认的开启数据库下划线驼峰命名转化,我们需要关闭。

spring:datasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql://localhost:3306/mybatisplususername: rootpassword: 123456mybatis-plus:configuration:log-impl: org.apache.ibatis.logging.stdout.StdOutImplmap-underscore-to-camel-case: false# 如果是放在src/main/java目录下 classpath:/com/*/*/mapper/*Mapper.xml# 如果是放在resource目录 classpath:/mapper/**.xml#mapper-locations: classpath:/mapper/**.xml

3.3、创建数据库和表信息

CREATE DATABASE mybatisplus;
USE mybatisplus;
CREATE TABLE student(stu_id VARCHAR(50),stu_name VARCHAR(30),stu_sex VARCHAR(2),stu_age VARCHAR(4),stu_addr VARCHAR(50),stu_pwd VARCHAR(50)
)DEFAULT CHARSET=utf8;
INSERT INTO student VALUES('1001','晓春','男','33','安徽合肥','1001');
INSERT INTO student VALUES('1002','陈平安','男','18','安徽合肥','1002');

3.4、创建bean对象

@TableName("student"):定义映射表信息

@TableId("stu_id"):定义数据库主键

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("student")
public class Student {@TableId("stu_id")private String stu_id;private String stu_name;private String stu_sex;private String stu_age;private String stu_addr;private String stu_pwd;
}

3.5、创建Mapper接口

public interface StudentMapper extends BaseMapper<Student> {
}

3.6、在启动类中扫描mapper接口

通过@MapperScan("com.txc.mybatisplus.mapper")注解扫描mapper接口,注意地址不能写错了。

@SpringBootApplication
@MapperScan("com.txc.mybatisplus.mapper")
public class Mybatisplusdemo1Application {public static void main(String[] args) {SpringApplication.run(Mybatisplusdemo1Application.class, args);}
}

3.7、功能1:查询所有学生信息

通过springweb创建一个测试类,查询student表中的所有学生信息

@RestController
public class StudentController {@Autowired(required = false)StudentMapper studentMapper;@RequestMapping("/testmybatisplus")@ResponseBodypublic void testMybatisPlus() {List<Student> list=studentMapper.selectList(null);//Assert.isTrue(5 == list.size(), "");list.forEach(System.out::println);}
}

3.8、功能2:模糊查询学生信息

说明1:queryWrapper.eq("stu_name","陈平安");//表示根据stu_name字段查询陈平安
       效果类似于:select * from student where stu_name=’陈平安’

说明2:queryWrapper.like("stu_addr","安徽合肥");//表示根据stu_addr模糊查询安徽合肥
       效果类似于
select * from student where stu_addr like ’%陈平安%’

两者合起来的效果是:

select * from student where stu_name=’陈平安’ and stu_addr like ’%陈平安%’;

@Controller
public class StudentController {@Autowired(required = false)StudentMapper studentMapper;//根据姓名查询学生信息@RequestMapping("/testMybatisPlusByName")@ResponseBodypublic void testMybatisPlusByName() {//QueryWrapper封装查询信息QueryWrapper<Student> queryWrapper=new QueryWrapper<>();//表示查询的时候表字段stu_name的值为陈平安queryWrapper.eq("stu_name","陈平安");//表示根据stu_addr模糊查询安徽合肥queryWrapper.like("stu_addr","安徽合肥");List<Student> list=studentMapper.selectList(queryWrapper);list.forEach(stu->{System.out.println(stu.getStu_name());});}

3.9、功能3:根据id查询学生信息

//根据id查询学生信息
@RequestMapping("/testMybatisPlusById")
@ResponseBody
public void testMybatisPlusById() {//QueryWrapper封装查询信息QueryWrapper<Student> queryWrapper=new QueryWrapper<>();//表示查询的时候表字段stu_name的值为陈平安queryWrapper.eq("stu_id","1001");Student stu=studentMapper.selectOne(queryWrapper);System.out.println(stu.toString());
}
}

3.10、功能3:添加学生信息

@Controller
public class StudentController {@Autowired(required = false)StudentMapper studentMapper;//添加学生信息@RequestMapping("/testMybatisPlusAdd")@ResponseBodypublic void testMybatisPlusAdd() {Student stu=new Student("1003","十一郎","男","34","安徽合肥","1003");studentMapper.insert(stu);System.out.println("=======数据添加成功========");}
}

3.11、功能4:修改学生信息

@Controller
public class StudentController {@Autowired(required = false)StudentMapper studentMapper;//修改学生信息@RequestMapping("/testMybatisPlusupdate")@ResponseBodypublic void testMybatisPlusupdate() {Student stu=new Student("1003","十一郎","男","34","安徽合肥","1003");studentMapper.updateById(stu);System.out.println("=======数据修改成功========");}
}

3.12、功能5:删除学生信息

@Controller
public class StudentController {@Autowired(required = false)StudentMapper studentMapper;//删除学生信息@RequestMapping("/testMybatisPlusDelete")@ResponseBodypublic void testMybatisPlusDelete() {Student stu=new Student();stu.setStu_id("1003");studentMapper.deleteById(stu);System.out.println("=======删除修改成功========");}
}

4、源码下载

源码属于vip资源,如果需要可在评论区留言,我修改成免费。

https://download.csdn.net/download/tangshiyilang/88276862

http://www.mmbaike.com/news/68181.html

相关文章:

  • 网站建设的特点网络优化主要做什么
  • 网站设计哪家公司好基础建站如何提升和优化
  • 制作网页的步骤是什么如何提高搜索引擎优化
  • 珠海企业网站建设服务电商软文广告经典案例
  • 临海网站制作58同城安居客
  • 网站的 营销渠道的建设企业网站建设的作用
  • 自己做网站开网店西安百度搜索排名
  • 郑州汉狮做网站的大公司关键词的优化方案
  • 网站优秀设计方案搜易网提供的技术服务
  • 山西住房和建设厅网站中国女排联赛排名
  • 网页界面设计的功能性主要体现在信息的哪两个方面培训班线上优化
  • 网站开发需要的资料seo查询 工具
  • 网站备案授权书怎么填写北京网站优化合作
  • 网站开发人员薪酬seo技术培训泰州
  • 有没有免费的网站软件seo搜索引擎优化人才
  • 网站建设分配人员方案十大软件免费下载网站排行榜
  • 大型手机网站制作产品软文模板
  • 网站调研方法有哪些内容谷歌优化教程
  • 休闲食品网站建设策划书公司网站怎么申请怎么注册
  • 西安企业网站制作价格百度推广渠道户
  • 建设网站第一步内蒙古网站seo
  • 装修公司网站 源码郴州网站seo外包
  • 沈阳模板网站制作论述搜索引擎优化的具体措施
  • 网站建设的方法站长网站工具
  • 比较大气的网站专业提升关键词排名工具
  • 做货代的要注册哪种物流网站怎么找专业的营销团队
  • 视频网站的服务器建设怎么做推广
  • 哪里可以学习做网站想做游戏推广怎么找游戏公司
  • 东莞高埗做网站哪个公司好徐州网站建设方案优化
  • 三网合一网站建设方案市场营销试题库(带答案)