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

休闲食品网站模板关键词优化软件有哪些

休闲食品网站模板,关键词优化软件有哪些,深圳网站开发建设培训机构,网站的栏目建设在哪里(一)Mybatis入门程序 1.创建springboot工程,并导入 mybatis的起步依赖、mysql的驱动包。(项目工程创建完成后,自动在pom.xml文件中,导入Mybatis依赖和MySQL驱动依赖) <dependencies> <!-- mybatis起步依赖 --> <dependency> …

(一)Mybatis入门程序

1.创建springboot工程,并导入 mybatis的起步依赖、mysql的驱动包。(项目工程创建完成后,自动在pom.xml文件中,导入Mybatis依赖和MySQL驱动依赖)

<dependencies>

        <!-- mybatis起步依赖 -->

        <dependency>

            <groupId>org.mybatis.spring.boot</groupId>

            <artifactId>mybatis-spring-boot-starter</artifactId>

            <version>2.3.0</version>

        </dependency>

        <!-- mysql驱动包依赖 -->

        <dependency>

            <groupId>com.mysql</groupId>

            <artifactId>mysql-connector-j</artifactId>

            <scope>runtime</scope>

        </dependency>

       

        <!-- spring单元测试 (集成了junit) -->

        <dependency>

            <groupId>org.springframework.boot</groupId>

            <artifactId>spring-boot-starter-test</artifactId>

            <scope>test</scope>

        </dependency>

</dependencies>

2. 准备数据(Mysql):创建用户表user,并创建对应的实体类User。

-- 用户表

create table user(

    id int unsigned primary key auto_increment comment 'ID',

    name varchar(100) comment '姓名',

    age tinyint unsigned comment '年龄',

    gender tinyint unsigned comment '性别, 1:男, 2:女',

    phone varchar(11) comment '手机号'

) comment '用户表';

-- 测试数据

insert into user(id, name, age, gender, phone) VALUES (null,'白眉鹰王',55,'1','18800000000');

insert into user(id, name, age, gender, phone) VALUES (null,'金毛狮王',45,'1','18800000001');

insert into user(id, name, age, gender, phone) VALUES (null,'青翼蝠王',38,'1','18800000002');

insert into user(id, name, age, gender, phone) VALUES (null,'紫衫龙王',42,'2','18800000003');

insert into user(id, name, age, gender, phone) VALUES (null,'光明左使',37,'1','18800000004');

insert into user(id, name, age, gender, phone) VALUES (null,'光明右使',48,'1','18800000005');

3. 在Idea中创建实体类:实体类的属性名与表中的字段名一一对应。

public class User {

    private Integer id;   //id(主键)

    private String name;  //姓名

    private Short age;    //年龄

    private Short gender; //性别

    private String phone; //手机号

   

    //省略GET, SET方法

}

4. 在之前使用图形化客户端工具,连接MySQL数据库时,需要配置参数:

 连接数据库的四大参数:

 - MySQL驱动类

 - 登录名

 - 密码

 - 数据库连接字符串

在springboot项目中,可以编写application.properties文件,配置数据库连接信息。我们要连接数据库,就需要配置数据库连接的基本信息,包括:driver-class-name、url 、username,password。

application.properties:

#驱动类名称

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

#数据库连接的url

spring.datasource.url=jdbc:mysql://localhost:3306/mybatis

#连接数据库的用户名

spring.datasource.username=root

#连接数据库的密码

spring.datasource.password=1234

 5.在创建出来的springboot工程中,在引导类所在包下,在创建一个包 mapper。在mapper包下创建一个接口 UserMapper ,这是一个持久层接口(DAO层)(Mybatis的持久层接口规范一般都叫 XxxMapper)。

import com.itheima.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
//@Mapper注解:表示是mybatis中的Mapper接口,程序运行时࿱
http://www.mmbaike.com/news/38543.html

相关文章:

  • 家教响应式网站seo小白入门教学
  • 乌鲁木齐中高端网站建设设计深圳网络营销渠道
  • 做网站后台的叫什么电池优化大师下载
  • 第三方网站做app推手平台哪个靠谱
  • 外国网站做问卷调查挣钱甘肃百度推广电话
  • 政府的网站是自己做的还是外包全网自媒体平台大全
  • python做网站方便么成人英语培训
  • 重庆做网站费用网店代运营一年的费用是多少
  • wordpress安装后浏览首页错位推广关键词如何优化
  • 网站建设的基本概念宁波seo网络推广咨询价格
  • 用友财务软件官方网站德州seo优化
  • 网站首页备案号链接品牌推广的渠道有哪些
  • 可靠的常州网站建设百度广告代理商查询
  • 专业网站排名优化公司铜川网络推广
  • 做网站需要会什么千万别在百度上搜别人名字
  • 浙江网站建设的要求百度指数如何提升
  • 做网站一般像素谷歌seo关键词优化
  • wordpress获取权限seo优化培训
  • 怎么做诈骗网站吗百度开户推广多少钱
  • 公司营销网站建设品牌策划方案范文
  • 网站 布局广告推广软文案例
  • 做网站的思想体会怎样进行seo
  • 做网站要备案吗腾讯企点怎么注册
  • 网站建设学生选课系统西安百度推广开户
  • 网站域名解释怎么做百度登录入口百度
  • 做网站游戏总结的例文职业技能培训中心
  • 公司网站开发公司新疆今日头条新闻
  • 珠海网站建设有限公司百度点击率排名有效果吗
  • cmd iis重启单个网站百度交易平台官网
  • 网站建设项目的预表万网的app叫什么