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

apache 配置网站地址PHP做网站的核心是什么

apache 配置网站地址,PHP做网站的核心是什么,wordpress yeti,北京律师网站建设推荐文章目录 前言一、准备1. 版本要求2.安装3. 建表语句 二、案例1. mapper2.实体类3.测试类4.扫描5. 配置6. mapper.xml7.输出 总结 前言 MyBatis-Spring-Boot-Starter 可以帮助你更快地在 Spring Boot 之上构建 MyBatis 应用。 一、准备 1. 版本要求 MyBatis-Spring-Boot-Sta… 文章目录 前言一、准备1. 版本要求2.安装3. 建表语句 二、案例1. mapper2.实体类3.测试类4.扫描5. 配置6. mapper.xml7.输出 总结 前言 MyBatis-Spring-Boot-Starter 可以帮助你更快地在 Spring Boot 之上构建 MyBatis 应用。 一、准备 1. 版本要求 MyBatis-Spring-Boot-StarterMyBatis-SpringSpring BootJava3.03.03.0 - 3.117 或更高2.32.12.5 - 2.78 或更高 2.安装 !-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter -- dependencygroupIdorg.mybatis.spring.boot/groupIdartifactIdmybatis-spring-boot-starter/artifactIdversion3.0.3/version /dependency3. 建表语句 CREATE TABLE user (id int NOT NULL,name varchar(255) NULL,age int NULL,brith_day date NULL,PRIMARY KEY (id) ); INSERT INTO springboot.user(id, name, age, brith_day) VALUES (1, 张三, 11, 2014-05-19); INSERT INTO springboot.user(id, name, age, brith_day) VALUES (2, 李四, 10, 2015-05-19);二、案例 正如你已经知道的 要与 Spring 一起使用 MyBatis你至少需要一个 SqlSessionFactory 和一个 mapper 接口。 MyBatis-Spring-Boot-Starter 将会 自动探测存在的 DataSource将使用 SqlSessionFactoryBean 创建并注册一个 SqlSessionFactory 的实例并将探测到的 DataSource 作为数据源将创建并注册一个从 SqlSessionFactory 中得到的 SqlSessionTemplate 的实例自动扫描你的 mapper将它们与 SqlSessionTemplate 相关联并将它们注册到Spring 的环境context中去这样它们就可以被注入到你的 bean 中 1. mapper package org.example.springboot3.mybatis.mappers;import org.apache.ibatis.annotations.Mapper; import org.example.springboot3.mybatis.model.User;import java.util.List;/*** Create by zjg on 2024/5/19*/ Mapper public interface UserMapper {ListUser selectList(); } 2.实体类 package org.example.springboot3.mybatis.model;import lombok.Getter; import lombok.Setter; import lombok.ToString;import java.util.Date;/*** Create by zjg on 2024/5/19*/ Getter Setter ToString public class User {private int id;private String name;private int age;private Date brithDay; } 3.测试类 package org.example.springboot3.mybatis.controller;import lombok.extern.log4j.Log4j2; import org.example.springboot3.mybatis.mappers.UserMapper; import org.example.springboot3.mybatis.model.User; 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;/*** Create by zjg on 2024/5/19*/ RequestMapping(/mybatis/) RestController Log4j2 public class UserController {AutowiredUserMapper userMapper;RequestMapping(001)public List mybatis001(){ListUser users userMapper.selectList();log.info(users);return users;} } 4.扫描 package org.example.springboot3;import org.mybatis.spring.annotation.MapperScan; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;MapperScan(org.example.springboot3.mybatis.mappers) RestController SpringBootApplication public class SpringBoot3Application {private static final Logger log LoggerFactory.getLogger(SpringBoot3Application.class);public static void main(String[] args) {ConfigurableApplicationContext run SpringApplication.run(SpringBoot3Application.class, args);String appName run.getEnvironment().getProperty(spring.application.name);log.info({}启动完成,appName);}RequestMapping(/)String home() {return Hello SpringBoot!;} }5. 配置 #mybatis mybatis:mapper-locations: mappers/**/*.xmltype-aliases-package: org.example.springboot3.mybatis.modeltype-handlers-package: org.example.springboot3.mybatis.typehandlerconfiguration:map-underscore-to-camel-case: truedefault-fetch-size: 100default-statement-timeout: 30更多配置请查看mybatis配置参数 6. mapper.xml !DOCTYPE mapperPUBLIC -//mybatis.org//DTD Mapper 3.0//ENhttps://mybatis.org/dtd/mybatis-3-mapper.dtdmapper namespaceorg.example.springboot3.mybatis.mappers.UserMapperselect idselectList resultTypeuserselect * from user/select /mapper7.输出 [2024-05-19 16:40:38.402][http-nio-8080-exec-1][INFO]- org.example.springboot3.mybatis.controller.UserController.mybatis001(UserController.java:23) - [User(id1, name张三, age11, brithDayMon May 19 00:00:00 CST 2014), User(id2, name李四, age10, brithDayTue May 19 00:00:00 CST 2015)]总结 回到顶部 架子这就搭好喽比上一章顺利多了。 更多内容请查看《Mybatis》系列文章目录
http://www.sczhlp.com/news/232087/

相关文章:

  • 做量化投资网站注册装修公司要多少钱才能注册
  • 谈谈对电子商务网站建设与管理商城网站建站
  • 外卖网站建设费用wordpress目录页seo
  • 网站对于企业的作用计算机培训机构培训出来好就业吗
  • .net 企业网站源码移动电子商务网站建设
  • 2025 年 10 月门窗十大品牌榜单揭晓,聚焦专业制造与品牌口碑的品质之选
  • [LangChain] 09.LCEL
  • [java 锁 02 - synchronized vs ReentrantLock ]
  • 10.26
  • 长沙企业网站开发直接IP做访问我服务器的网站
  • 怎么做网站文章优化精通网站建设pdf
  • 网站域名和网址一样吗网页制作用什么软件做
  • 网站备案主体是什么意思公司网站建立费用
  • 著名的响应式网站有哪些影院禁止18岁以下观众入内
  • 织梦网站根目录常德营销型网站建设
  • 沈阳网站建设技术公司雏鸟短视频app软件下载网站
  • 哪个网站音乐做的最好中国建设法律法规网官方网站
  • 网站每个月8g流量如何做百度推广的网站
  • 网站免费优化网站建设的流程步骤
  • 织梦网站专题模板深圳网站备案查询
  • 个人做哪方面的网站深圳返利网站开发
  • 建设网站女装名字大全大连做企业网站的公司
  • 中国外贸网站大全沧州网站制作
  • asp.net 获取网站的绝对路径常州网站制作建设
  • 龙华做网站多少钱铜山网站建设
  • 镇江门户网站广州网站建设网站托管运营
  • 做的好的音乐网站的特点晋中建设集团网站
  • iis7 发布asp网站404小馋网站建设书
  • 网站运营的概念cms 官方网站
  • 即时通讯网站开发源码2023年简短新闻三十条