目录
1. 创建一个SpringBoot项目,添加Lombok,MySQL Driver,Web依赖
(1) 组名和工件名的作用
1、groupid和artifactId被统称为“坐标”是为了保证项目唯一性而提出的,如果你要把你项目弄到maven本地仓库去,你想要找到你的项目就必须根据这两个id去查找。
2、groupId和artifactId是maven管理项目包时用作区分的字段,就像是地图上的坐标。
3、artifactId:artifactId一般是项目名或者模块名。
4、groupId一般分为多个段,这里我只说两段,第一段为域,第二段为公司名称。域又分为org、com、cn等等许多,其中org为非营利组织,com为商业组织。举个apache公司的tomcat项目例子:这个项目的groupId是org.apache,它的域是org(因为tomcat是非营利项目),公司名称是apache,artigactId是tomcat。
5、比如我自己新建的项目,cn.wjm.testProj,cn是域名,wjm是我自己的姓名缩写,testProj是项目名
该段文字来自:新建项目时的Group和Artifact是什么
(2) 添加依赖项
2. 新建远程Git仓库,并与本地仓库连接
(1) 新建远程仓库
(2) 构建本地仓库,并定义其远程
从远程仓库中复制SSH地址,添加到下图URL中:
3. 创建并连接数据库
(1) 连接数据库
将用户与密码输入完成后,点击测试连接,测试成功就可以点击应用并确定了,若测试失败,可能是本地MySQL未启动导致,可在任务管理器的服务中找到MySQL并启动:
版本在8.0.x的会有MySQL和MySQL80两个服务,选择任意一个即可。
可以通过该链接了解: MySQL和MySQL80的区别
(2) 在application.properties文件中配置MySQL的驱动和数据库信息三要素
(3)初始化数据库(选)
我是使用Kimi帮我通过我的表生成的数据,仅做测试学习使用:
create table dept
(
id int unsigned primary key auto_increment comment '主键ID',
name varchar(10) not null unique comment '部门名称',
create_time datetime not null comment '创建时间',
update_time datetime not null comment '修改时间'
) comment '部门表';
create table emp
(
id int unsigned primary key auto_increment comment 'ID',
username varchar(20) not null unique comment '用户名',
password varchar(32) default '123456' comment '密码',
name varchar(10) not null comment '姓名',
gender tinyint unsigned not null comment '性别,说明:1男,2女',
image varchar(300) comment '图像'