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

图书馆建设投稿网站网站建设与运营的预算方案模板

图书馆建设投稿网站,网站建设与运营的预算方案模板,软件技术特点,网站开发费属于软件费吗哈喽#xff0c;大家好#xff0c;我是有勇气的牛排#xff08;全网同名#xff09;#x1f42e;#x1f42e;#x1f42e; 有问题的小伙伴欢迎在文末评论#xff0c;点赞、收藏是对我最大的支持#xff01;#xff01;#xff01;。 Spring Data了解下#xff1…哈喽大家好我是有勇气的牛排全网同名 有问题的小伙伴欢迎在文末评论点赞、收藏是对我最大的支持。 Spring Data了解下 Spring Data官网https://docs.spring.io/spring-data/jpa/docs/current/reference/html/ Spring Data主要为数据访问提供一个相似的、一致的、基于Spring的编程模型同时保留各个数据库的存储特征这使得数据访问技术变得非常简单。 常用的整合数据模型有Jdbc、MyBatis、durid 1 准备数据库 CREATE TABLE users (id int(11) NOT NULL AUTO_INCREMENT,name varchar(32) NOT NULL COMMENT 用户名称,age int(11) DEFAULT NULL,PRIMARY KEY (id) ) ENGINEInnoDB AUTO_INCREMENT3 DEFAULT CHARSETutf8;insert into users values (null, 有勇气的牛排1, 18); insert into users values (null, 有勇气的牛排2, 19); insert into users values (null, 有勇气的牛排3, 20);2 整合 JdbcTemplate JdbcTemplate类是Spring对JDBC支持的核心它提供了对数据库所有功能操作的支持。 2.1 pom依赖 !-- SpringBoot整合jdbc 模板框架 -- dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-jdbc/artifactId /dependency !-- SpringBoot整合mysql驱动类 -- dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.21/version /dependency2.2 application.yml spring:# 整合 JdbcTemplatedatasource:url: jdbc:mysql://localhost:3306/cs_test_springbootusername: rootpassword: root123456driver-class-name: com.mysql.jdbc.Driver2.3 后端 /** Author : 有勇气的牛排* FileName: UserService_jdbcTemplate.java* desc :* */package com.couragesteak.service;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class UserService_jdbcTemplate {Autowiredprivate JdbcTemplate jdbcTemplate;/** 插入数据到user表* */// http://127.0.0.1:8080/insertUser?userNamecs666age21RequestMapping(/insertUser)public String insertUser(String userName, Integer age) {int update jdbcTemplate.update(insert into users values (null, ?, ?), userName, age);return update 0 ? success : fail;} }3 整合MyBatis MyBatis是一个优秀的持久层框架它对jdbc的操作数据库的过程进行了封装使开发者只需要关注SQL本身而不需要花费精力去处理注册驱动、创建connection、创建statement、手动设置参数等操作。 3.1 Maven依赖 !-- springboot 整合mybatis -- dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion1.1.1/version /dependency dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.21/version /dependency3.2 application.yml !-- springboot 整合mybatis -- dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion1.1.1/version /dependency !-- SpringBoot整合mysql驱动类 -- dependencygroupIdmysql/groupIdartifactIdmysql-connector-java/artifactIdversion5.1.21/version /dependency3.3 用户实体 UserEntity.java /** Author : 有勇气的牛排* FileName: UserEntity.java* desc :* */package com.couragesteak.entity;public class UserEntity {private Integer id;private String userName;private Integer age;public UserEntity() {}public UserEntity(String userName, Integer age) {this.userName userName;this.age age;}public UserEntity(Integer id, String userName, Integer age) {this.id id;this.userName userName;this.age age;}public Integer getId() {return id;}public void setId(Integer id) {this.id id;}public String getUserName() {return userName;}public void setUserName(String userName) {this.userName userName;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age age;} } 3.4 Mapper 接口: UserMapper.java package com.couragesteak.mapper;import com.couragesteak.entity.UserEntity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select;public interface UserMapper {Insert(insert into users values (null, #{userName}, #{age});)int insertUser(Param(userName) String userName, Param(age) Integer age);Select(select id, name, age from users where id#{id})UserEntity selectByUserId(Param(id) Integer id); }3.5 后端 /** Author : 有勇气的牛排* FileName: UserService_MyBatis.java* desc :* */package com.couragesteak.service;import com.couragesteak.entity.UserEntity; import com.couragesteak.mapper.UserMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class UserService_MyBatis {Autowiredprivate UserMapper userMapper;/*** MyBatis 查询数据*/// http://127.0.0.1:8080/mybatis_findUser?id3RequestMapping(/mybatis_findUser)public UserEntity mybatis_FindUserById(Integer id) {System.out.println(mybatis_FindUserById);System.out.println(id);return userMapper.selectByUserId(id);}/*** MyBatis 插入数据*/// http://127.0.0.1:8080/mybatis_insertUser?userNamecs7age22RequestMapping(/mybatis_insertUser)public String mybatis_insertUser(String userName, Integer age) {int insert userMapper.insertUser(userName, age);return insert 0 ? success : fail;} }参考地址 https://www.couragesteak.com/article/289余胜军
http://www.hkea.cn/news/14485501/

相关文章:

  • vps可以用了做网站吗威联通如何做网站
  • 常德网站建设网站优化网站制作客户资料
  • 在线玩的游戏网站优化的近义词
  • 职业生涯规划大赛的意义深圳免费网站优化网络推广
  • 东阳网站建设价格家庭宽带 做网站
  • 小规模公司做网站成本是什么河北高阳做网站的
  • 电子商务网站建设试题3哪个网站可以做奖状
  • 基于漏斗模型网站关键路径分析安徽网络优化
  • 做网站前台内容对应填充做电影网站程序哪个好
  • wordpress网站搭建教程韶关哪里做网站
  • 手机如何建设网站首页网站备案法律
  • 江苏建设招投标网优化资源配置
  • 网站登录和权限怎么做优设网app安卓下载
  • 做网站网站违法吗升级wordpress5.0
  • 买奢侈品去哪个网站有正品怎么做赛事直播网站
  • 网站服务是指小程序商城开源
  • 百度一般多久收录网站摄影网站怎么备案
  • 网站推广关键词工具wordpress 邮件推送
  • 金山网站建设推广天津全包圆装饰公司官网
  • 仿网站教程佛山专业网站开发公司
  • 做游戏陪玩网站南京专业网站设计哪个品牌
  • 网站精神文明建设专栏网站设计哪家强
  • 电脑什么软件做短视频网站wordpress换主题首页错乱
  • 网站树状结构图怎么做北京网页网站设计制作
  • 中山做app网站公司哪家好设计师专业网站
  • 长安网站优化广州学习做网站建设的学校
  • 做网站推广都有哪些行业长沙网站建设联系电话
  • 实惠的网站建设Wordpress页面添加小工具
  • 网站建设和网站推广可以同一家做吗在一个网站的各虚拟目录中默认文档的文件名要相同
  • win7 做服务器开网站asp网站开发招聘