怎样建官方网站北京 企业建网站

diannao/2026/1/20 14:00:14/文章来源:
怎样建官方网站,北京 企业建网站,企业网络营销的推广方法,网页设计公司简介模板建立连接可能涉及到的问题#xff08;只需要自己改一下就行#xff09; 1、MyBatis是⼀款优秀的 持久层 框架#xff0c;⽤于简化JDBC的开发 2、数据库连接配置 #xff08;1#xff09;yml配置 # 数据库连接配置 spring:datasource:url: jdbc:mysql://127.0.0.1:3306/…建立连接可能涉及到的问题只需要自己改一下就行 1、MyBatis是⼀款优秀的 持久层 框架⽤于简化JDBC的开发 2、数据库连接配置 1yml配置 # 数据库连接配置 spring:datasource:url: jdbc:mysql://127.0.0.1:3306/mybatis_test? characterEncodingutf8useSSLfalseusername: rootpassword: rootdriver-class-name: com.mysql.cj.jdbc.Driver 2properties配置 #驱动类名称 spring.datasource.driver-class-namecom.mysql.cj.jdbc.Driver #数据库连接的url spring.datasource.urljdbc:mysql://127.0.0.1:3306/mybatis_test? characterEncodingutf8useSSLfalse #连接数据库的⽤⼾名 spring.datasource.usernameroot #连接数据库的密码 spring.datasource.passwordroot 3、数据库建表代码 -- 创建数据库 DROP DATABASE IF EXISTS mybatis_test; CREATE DATABASE mybatis_test DEFAULT CHARACTER SET utf8mb4; -- 使⽤数据数据 USE mybatis_test; -- 创建表[⽤⼾表] DROP TABLE IF EXISTS userinfo; CREATE TABLE userinfo (id INT ( 11 ) NOT NULL AUTO_INCREMENT,username VARCHAR ( 127 ) NOT NULL,password VARCHAR ( 127 ) NOT NULL,age TINYINT ( 4 ) NOT NULL,gender TINYINT ( 4 ) DEFAULT 0 COMMENT 1-男 2-⼥ 0-默认,phone VARCHAR ( 15 ) DEFAULT NULL,delete_flag TINYINT ( 4 ) DEFAULT 0 COMMENT 0-正常, 1-删除,create_time DATETIME DEFAULT now(),update_time DATETIME DEFAULT now(),PRIMARY KEY ( id ) ) ENGINE INNODB DEFAULT CHARSET utf8mb4; -- 添加⽤⼾信息 INSERT INTO mybatis_test.userinfo ( username, password, age, gender, phone ) VALUES ( admin, admin, 18, 1, 18612340001 ); INSERT INTO mybatis_test.userinfo ( username, password, age, gender, phone ) VALUES ( zhangsan, zhangsan, 18, 1, 18612340002 ); INSERT INTO mybatis_test.userinfo ( username, password, age, gender, phone ) VALUES ( lisi, lisi, 18, 1, 18612340003 ); INSERT INTO mybatis_test.userinfo ( username, password, age, gender, phone ) VALUES ( wangwu, wangwu, 18, 1, 18612340004 ); 4、需要引入的pom文件依赖 dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion2.3.1/version/dependencydependencygroupIdcom.mysql/groupIdartifactIdmysql-connector-j/artifactIdscoperuntime/scope/dependencydependencygroupIdtk.mybatis/groupIdartifactIdmapper/artifactIdversion4.0.0/version/dependency 5、数据库查询代码 1接口 package com.example.demo;import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select;import java.util.List;Mapper public interface UserInfoMapper {//访问数据库数据Select(select * from userinfo)ListUserInfo queryUserList(); } 2定义对象 package com.example.demo; import lombok.Data; import java.util.Date;Data public class UserInfo {//数据库里面有什么我们这里就定义什么private Integer id;private String username;private String password;private Integer age;private Integer gender;private String phone;private Integer deleteFlag;private Date createTime;private Date updateTime; } 3测试类 package com.example.demo;import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest;SpringBootTest class DemoApplicationTests {Autowired private UserInfoMapper userInfoMapper;Testvoid contextLoads() {System.out.println(userInfoMapper.queryUserList());} } 6、数据删除方式有两种 1逻辑删除update推荐 2物理删除delete 7、在Mybatis当中我们可以借助⽇志, 查看到sql语句的执⾏、执⾏传递的参数以及执⾏结果在配置⽂件中进⾏配置 mybatis:configuration: # 配置打印 MyBatis⽇志log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 8、生成测试测试类上面要加SpringBootTest 9、单参查寻只有一个参数时#后面的名称无所谓随便定义 1接口部分代码 Select(select * from userinfo where id #{userId})UserInfo queryUserInfo(Integer userId); 2测试部分代码 void queryUserInfo() {log.info(userInfoMapper.queryUserInfo(1).toString());} 10、多参数时 1接口部分代码idea上面创建的代码阿里云创建的不能应用此方法 Select(select * from userinfo where id #{userId} and delete_flag #{deleteFlag})UserInfo queryUserInfo( Integer userId, Integer deleteFlag); 1接口部分代码阿里云创建的项目代码 Select(select * from userinfo where id #{param1} and delete_flag #{param2})UserInfo queryUserInfo(Integer id, Integer deleteFlag); 2测试部分代码 void testQueryUserInfo() {log.info(userInfoMapper.queryUserInfo(1,0).toString());} 11、参数重命名重命名之后不能用之前的 1接口部分代码 Select(select * from userinfo where id #{id} and delete_flag #{param2})UserInfo queryUserInfo(Param(id) Integer id, Integer deleteFlag); 2测试部分代码 void testQueryUserInfo() {log.info(userInfoMapper.queryUserInfo(1,0).toString());} 12、web调用查询代码三层架构模式 1Controller代码 package com.example.demo;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;import java.util.List;RestController RequestMapping(/user) public class UserController {Autowiredprivate UserService userService;RequestMapping(/queryAllUser)public ListUserInfo queryAllUser(){return userService.queryAllUser();} } 2Service代码 package com.example.demo;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;import java.util.List;Service public class UserService {Autowiredprivate UserInfoMapper userInfoMapper;public ListUserInfo queryAllUser(){return userInfoMapper.queryUserList();} }3Mapper代码 package com.example.demo;import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select;import java.util.List;Mapper public interface UserInfoMapper {//访问数据库数据Select(select * from userinfo)ListUserInfo queryUserList(); } 4查询结果 13、插入数据 1接口部分代码 Select(insert into userinfo (username,password,age,gender,phone) values(#{username},#{password},#{age},#{gender},#{phone}))Integer insert(UserInfo userInfo); 2测试部分代码 Testvoid insert() {UserInfo userInfonew UserInfo();userInfo.setUsername(zhangsan);userInfo.setPassword(123456);userInfo.setAge(18);userInfo.setGender(0);userInfo.setPhone(18330322);userInfoMapper.insert(userInfo);} 3重命名的方式 Select(insert into userinfo (username,password,age,gender,phone) values(#{userInfo.username},#{userInfo.password},#{userInfo.age},#{userInfo.gender},#{userInfo.phone}))Integer insert(Param(userInfo) UserInfo userInfo); 4获得自增的数据比如我们买东西我们可以看我们买了多少东西这样有个数 4.1接口部分代码 Options(useGeneratedKeys true,keyProperty id)Insert(insert into userinfo (username,password,age,gender,phone) values(#{username},#{password},#{age},#{gender},#{phone}))Integer insert(UserInfo userInfo); 4.2测试部分代码 Testvoid insert() {UserInfo userInfonew UserInfo();userInfo.setUsername(zhangsan);userInfo.setPassword(123456);userInfo.setAge(18);userInfo.setGender(0);userInfo.setPhone(18330322);Integer result userInfoMapper.insert(userInfo);log.info(插入了几条数据result自增Id是userInfo.getId());} 14、删除数据 1接口部分代码 Delete(delete from userinfo where id#{id})Integer delete(Param(id) Integer id); 2测试部分代码 Testvoid delete() {userInfoMapper.delete(11);} 15、更改数据 1接口部分代码idea创建的项目 Update(update userinfo set password#{password} where id#{id})Integer update(String password,Integer id); 1接口部分代码阿里云创建的项目 Update(update userinfo set password#{param1} where id#{param2})Integer update(String password,Integer id); 2测试部分代码 Testvoid update() {userInfoMapper.update(777777,12);} 15.1、放在对象里更新 1接口部分代码 Update(update userinfo set username#{username},password#{password},age#{age} where id#{id})Integer update(UserInfo userInfo); 2测试部分代码 Testvoid update() {UserInfo userInfonew UserInfo();userInfo.setUsername(lisi);userInfo.setPassword(987654);userInfo.setAge(10);userInfo.setId(12);userInfoMapper.update(userInfo);} 16、mybatis赋值失败原因 1解决办法 1.1改别名 用as的方法 Select(select id,username,password,age,phone, delete_flag as deleteFlag,create_time as createTime,update_time as updateTime from userinfo)ListUserInfo queryUserList(); 1.2注解方式 Results({Result(column delete_flag,property deleteFlag),Result(column create_time,property createTime),})Select(select * from userinfo)ListUserInfo queryUserList(); 1.31.2的Results的复用 Results(id base,value {Result(column delete_flag,property deleteFlag),Result(column create_time,property createTime),})Select(select * from userinfo)ListUserInfo queryUserList();ResultMap(value base)Select(select id,username,password,age,phone,delete_flag ,create_time,update_time from userinfo)UserInfo queryUserInfo( Integer userId, Integer deleteFlag); ♥1.4开启驼峰命名(推荐) 直接配置yml文件 mybatis:configuration:map-underscore-to-camel-case: true

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/diannao/89946.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

南充公司做网站建设南大街小学网站

大数据法律监督平台是基于监督数据整合管理平台、监督模型构建平台、内置模型库以及法律监督线索管理平台打造的一套服务于检察机关法律监督工作的专业化系统。通过数据采集、融合、挖掘、建模、展现等一系列能力,辅助检察官从纷繁复杂的数据中,开展多维…

如何做机票预订网站网站素材设计

实验环境——vulnhub-dc2靶场 git提权 前提:用户可以使用sudo中git权限 查看sudo权限 sudo -l可以发现git命令存在sudo提权 基于此进行权限提升 方式: sudo git help config #在末行命令模式输入 !/bin/bash 或 !sh #完成提权 sudo git -p help…

seo服务器配置seo广告投放

1.若有char w; int x; float y; double z; 则表达式w*xz-y值的数据类型为( )。 (2分) A.float B.char C.int D.double D 解析: 整形和浮点型计算,结果为浮点型;单精度和双精度计算,结果为双精度 因为在计算…

网站备案查询不到网站备案掉了怎么办

在 golang中,想要并发安全的操作map,可以使用sync.Map结构,sync.Map 是一个适合读多写少的数据结构,今天我们来看看它的设计思想,来看看为什么说它适合读多写少的场景。 如下,是golang 中sync.Map的数据结构…

wordpress html5的关系网站建设优化开发公司

input输入 (默认输入: 苹果🍎 橘子🍊 梨子🍐 葡萄🍇空一行空值表示结束输入input添加 1. 添加 2. 删除 序号和文字都可以,要空格或者空行 可以点对点输入数据深色主题 mpl_style(darkTrue)# 折线…

阿里云轻量级服务器搭建wordpressseo优化搜索结果

在C#中,ref和out关键字用于按引用传递变量,它们在变量传递、输出参数、返回值以及异常处理等方面有一些重要区别。本文将详细阐述这些差异。 1. 变量传递 ref和out关键字都可以用于方法的参数传递。它们的主要区别在于如何处理变量的引用。 ref关键字…

遵义市做网站公司网站开发设计师岗位职责

↑ ↑ ↑ ↑ ↑ 请看文件夹 ↑ ↑ ↑ ↑ ↑ 下载 / 安装 windows / MAC OS 官网下载,双击安装,这个都会吧~ linux linux下安装,一种办法是从官网下载 tar.bz ,手动安装。 这里介绍用 apt-get 自己主动安装方法&#xf…

做网站需要什么步骤优秀设计网站

Tag 【动态规划】【数组】 题目来源 70. 爬楼梯 题目解读 有过刷题「动态规划」刷题经验的读者都知道,爬楼梯问题是一种最典型也是最简单的动态规划问题了。 题目描述为:你每次可以爬 1 或者 2 个台阶,问爬上 n 阶有多少种方式。 解题思路…

泰安网站开发网站排名优化技巧

A - 一方通行和最大公约数I CodeForces - 664A 作为学园都市最强的lv5,一方通行必须解决一道数学题才能接触last order身上植入的病毒,请你帮他解决这个问题。给出两个整数a,b 求出[a,b]区间中所有整数的最大公约数。输入输入包括一行,一…

外贸网站推广wordpress 简书风格

前言: I2C(Inter-Integrated Circuit)总线(也称 IIC 或 I2C) 是有PHILIPS公司开发的两线式串行总线,用于连接微控制器及外围设备,是微电子通信控制领域广泛采用的一种总线标准。它是同步通信的一种特殊形式,具有接口线少、控制方式…

网页与网站的区别和关系校园网络设计报告

嵌入式 lnmp搭建的记录 N:NginxP:php编译PHP可能遇到的问题configure阶段:Makefile-make阶段:Makefile-make install阶段: 文章比较水,并没有没解决什么实际问题,有点不好意思发布。但好像又记录…

智通人才网东莞最新招聘信息网站优化需要

给定一个整数数组 nums&#xff0c;处理以下类型的多个查询: 计算索引 left 和 right &#xff08;包含 left 和 right&#xff09;之间的 nums 元素的 和 &#xff0c;其中 left < right 实现 NumArray 类&#xff1a; NumArray(int[] nums) 使用数组 nums 初始化对象 in…

ppt模板免费网站在线制作wordpress可以做网站吗

Python有四种类型的数字:1.整型 a = 2 print a 2.长整型 b = 123456789 print b 3.浮点数 c = 3.2E2 print c 4.复数 复数为实数的推广,它使任一多项式都有根。复数当中有个“虚数单位”j,它是-1的一个平方根。任一复数都可表达为x+yj,其中x及y皆为实数,分别称为复数之“实…

淘宝网站制作多少钱泰州建站程序

Kong标准软件基于Bitnami apache 构建。当前版本为2.4.58 你可以通过轻云UC部署工具直接安装部署&#xff0c;也可以手动按如下文档操作&#xff0c;该项目已经全面开源&#xff0c;可以从如下环境获取 配置文件地址: https://gitee.com/qingplus/qingcloud-platform qinghub…

做阀门的网站在58同城做网站有生意吗

除了联合查询注入&#xff0c;报错注入&#xff0c;盲注注入 sql注入还有以下几类&#x1f9b9;&#x1f9b9;&#x1f9b9;&#x1f9b9;&#x1f9b9; 开始填坑 1.UA注入 原理&#xff1a;有些网站会把用户的UA信息写入数据库&#xff0c;用来收集和统计用户…

校园网网站建设规划书合肥关键词排名技巧

目录 1 560. 和为 K 的子数组 2 239. 滑动窗口最大值 3 76. 最小覆盖子串 菜鸟做题第二周&#xff0c;语言是 C 1 560. 和为 K 的子数组 题眼&#xff1a;“子数组是数组中元素的连续非空序列。” 解决本问题的关键就在于如何翻译问题。子数组 s 的和可以看作数组 i 的…

自然人做音频网站违法吗网站的备案的要多少钱

在OpenStack环境中&#xff0c;虚拟机的迁移可以通过多种方式实现&#xff0c;包括实时迁移&#xff08;Live Migration&#xff09;和冷迁移&#xff08;Cold Migration&#xff09; 实时迁移&#xff08;Live Migration&#xff09; 实时迁移是在虚拟机运行的同时将其迁移到…

网上商城网站开发报告网站无备案

MaxCompute 按量计费资源为弹性伸缩资源&#xff0c;对于计算任务&#xff0c;按任务需求提供所需资源&#xff0c;对资源使用无限制&#xff0c;同时MaxCompute按量计费的账单为天账单&#xff0c;即当天消费需要第二天才出账&#xff0c;因此&#xff0c;有必要对计算任务的消…

容桂做pc端网站黑白网站设计

6月26日&#xff0c;2024年世界移动通信大会&#xff08;MWC上海&#xff09;如期举行&#xff0c;今年的展会以“未来先行”为主题&#xff0c;涵盖“超越 5G、数智制造和人工智能经济”三大技术主题。移远通信作为全球物联网行业的引领者之一&#xff0c;今年不仅在展示内容上…