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

网站开发需要什么资料贵阳网站制作软件

网站开发需要什么资料,贵阳网站制作软件,哪家公司网站制作好,WordPress+百度+主动前言 前面快速学习了Mybatis,现在开始快速学习MyBatisPlus 学习教程: 黑马mybatis教程全套视频教程,2天Mybatis框架从入门到精通 黑马程序员最新MybatisPlus全套视频教程,4小时快速精通mybatis-plus框架 简介 MyBatisPlus 是…

前言

前面快速学习了Mybatis,现在开始快速学习MyBatisPlus

学习教程:
黑马mybatis教程全套视频教程,2天Mybatis框架从入门到精通

黑马程序员最新MybatisPlus全套视频教程,4小时快速精通mybatis-plus框架

简介

MyBatisPlus 是基于MyBatis框架基础上开发的增强型工具,旨在简化开发、提高效率。

创建项目

创建项目

问了一下后端同事建议是创建一个springboot项目,在springboot项目里使用mybatis-plus。参考了两篇文章给弄出来了,下面是基本步骤,如果遇到啥问题别找我,不会。我是搞前端开发的,学后端属于公司要求。

参考的文章:

搭建SpringBoot项目三种方式(超详细版)

Spring Boot + MyBatis + MySQL框架搭建

1、修改为阿里源
https://start.aliyun.com/
在这里插入图片描述
2、设置项目名称、其他配置
在这里插入图片描述
3、选择springboot版本和依赖
在这里插入图片描述
4、下载依赖并运行
下载完依赖后切换到SpringbootApplication.java文件里,点击运行
在这里插入图片描述
运行成功,并且能在浏览器里访问,证明项目成功
在这里插入图片描述

项目配置

添加mybatis-plus和mysql依赖
pom.xml里添加依赖

<!-- mybatis plus-->
<dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.5.1</version>
</dependency>
<!-- mysql-->
<dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.28</version>
</dependency>

mysql的依赖要与你的mysql保持一致。

添加完依赖后下载。

配置数据库信息
src/main/resources/application.properties文件里添加数据库信息

# MySQL
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=123abc!@#
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

创建实体类
src/main/java/org/example/springboot文件夹下创建entity文件夹,用于存放实体类。在entity下创建实体类User.java

public class User {Integer id;String name;Integer age;String email;Integer sex;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}public String getEmail() {return email;}public void setEmail(String email) {this.email = email;}public Integer getSex() {return sex;}public void setSex(Integer sex) {this.sex = sex;}@Overridepublic String toString() {return "User{" +"id=" + id +", name='" + name + '\'' +", age=" + age +", email='" + email + '\'' +", sex=" + sex +'}';}}

创建mapper接口
src/main/java/org/example/springboot文件夹下创建mapper文件夹,用于存放实体类。在mapper下创建接口UseMapperr.java

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.example.springboot.entity.User;import java.util.List;// 继承mybatis-plus的BaseMapper接口
@Mapper
public interface UserMapper extends BaseMapper<User> {// 查询所有用户List<User> selectAllUser();
}

创建UserMapper.xml

src/main/resources目录下创建一个名为mapper的文件夹,并在其中创建一个名为UserMapper.xml的文件。这里要注意的是文件路径不要错了。

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapperPUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd"><!--
namespace: 命名空间
resultType:返回值的类型,一般是实体类
id:唯一标识
-->
<mapper namespace="org.example.springboot.mapper.UserMapper"><resultMap id="userResultMap" type="org.example.springboot.entity.User"><!-- property 属性是指对应的 Java 类的属性,column 属性是指对应的数据库表的字段名 --><!-- 主键映射--><id property="id" column="id"/></resultMap><!--  查询所有用户--><select id="selectAllUser" resultMap="userResultMap">select *from user;</select></mapper>

创建Service和Controller
src/main/java/org/example/springboot文件夹下创建service文件夹。在service下创建接口UserService.java

import org.example.springboot.entity.User;
import org.example.springboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;@Service
public class UserService {@Autowiredprivate UserMapper userMapper;public List<User> selectAllUser() {// 查询id12的用户List<Integer> idList = new ArrayList<>();idList.add(1);idList.add(2);return userMapper.selectBatchIds(idList);}
}

src/main/java/org/example/springboot文件夹下创建controller文件夹。在controller下创建接口UserController.java

import org.example.springboot.entity.User;
import org.example.springboot.service.UserService;
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.ResponseBody;import java.util.List;@Controller
public class UserController {@Autowiredprivate UserService userService;@RequestMapping("/userlist")@ResponseBodypublic List<User> selectAllUser() {return userService.selectAllUser();}
}

测试
重启项目,在浏览器里访问userlist,看能否从数据库获取到数据
在这里插入图片描述

http://www.yayakq.cn/news/721242/

相关文章:

  • 网站调用网页内容网站指向wordpress
  • 网站经常被挂马企业网站首页布局尺寸
  • 网站建设需要的资质网络口碑营销案例分析
  • 网站建设 找客户重庆好的网站建设
  • 网站没有备案可以做百度推广吗国内外html5网站建设状况
  • 网站维护和建设工作范围有哪些学校的网站做的好
  • 怎样给网站做百度推广wordpress音乐播放显示歌词
  • 赣州网站设计有哪些西安百度爱采购推广
  • 商城系统网站模板免费下载使用jquery的网站
  • 口碑好的定制网站建设公司泉州手机网站开发
  • 天津网站的优化专业二维码网站建设
  • 网站的小图标怎么做的微信云开发文档
  • 建设工程公司网站国外做饮料视频网站
  • 外卖网站建设可行性分析怎么做网页小猪佩奇
  • 0716网站建设多媒体网站设计开发是指什么
  • 如何做新网站茶文化网站建设内容
  • 做企业网站10万起步辽宁省建设工程信息网盲盒系统
  • 网站用户 分析wordpress教程 迅雷
  • 网站建设买服务器还是数据库保定网站优化排名
  • 站长之家查询网站wordpress 中文主题
  • 网站 网页区别是什么小游戏网页版在线玩
  • 什么行业做网站多百度文档怎么免费下vvv
  • 做网站对客户有什么帮助一个前端页面多少钱
  • 网站建设 科技公司公司网站建设的基本流程
  • 网站项目规划与设计河北大城县网站建设公司
  • 做网站过时了官方网站欣赏
  • 网站建设文化机构排行榜哪个网站最好
  • 怎么做网站链接的快捷方式php成品网站超市
  • 营销网站制作皆选ls15227负责网站上线前准备方案
  • 网站标题的关键字怎么写wordpress充值插件