目录
1.搭建环境
1.1 检查JDK
确认JDK版本为1.8
1.2 检查MySQL数据库
确认MySQL版本为 5.7.x
1.3 检查 Maven
确认版本为3.8.X及以上自己安装Maven环境时,验证,打开终端输入 mvn-v,输出如下信息说明配置成功
1. 部署方式
2. 安装步骤
2.1 从官网下载-个Maven 3.8.X
2.2 配置Maven的环境变量
配置环境变量很简单,所以此处省略
2.3 配置国内的镜像
<!-- 加入如下mirror节点 使用国内阿里云仓库镜像 开始-->
<mirror>
<id>aliyun-public</id>
<mirrorOf>*</mirrorOf>
<name>aliyun public</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>aliyun-central</id>
<mirrorOf>*</mirrorOf>
<name>aliyun central</name>
<url>https://maven.aliyun.com/repository/central</url>
</mirror>
<mirror>
<id>aliyun-spring</id>
<mirrorOf>*</mirrorOf>
<name>aliyun spring</name>
<url>https://maven.aliyun.com/repository/spring</url>
</mirror>
<!-- 加入如下mirror节点 使用国内阿里云仓库镜像 结束-->
2.4 IDEA
1.4 检查GITEE + GIT
1.5 安装插件
1. 安装 Spring Boot Helper
2. 安装Lombok
1.6 创建仓库
1.登录GITEE创建仓库并复制仓库地址
2.克隆到本地
1.7 创建工程
1.使用国内镜像网站创建
2.创建
3.识别maven工程
(1)如果有通知
下图就是成功了
(2)没有通知就添加maven框架
1.8 调整项目配置
1.maven配置
1.1 报错:maven打包的时候出现 JDK 无效
会提示找不到JDK11 或者是让你填入正确的JDK路径。
修改bug方案如下图:
2.编码配置
3.代码补全配置
4.自动导包配置
5. 开启热部署
6.JDK版本配置
<!--JDK的版本号-->
<java.version>1.8</java.version>
<!--编译环境的JDK版本-->
<maven.compiler.source>${java.version}</maven.compiler.source>
<!--运行环境JVM版本-->
<maven.compiler.target>${java.version}</maven.compiler.target>
<!--构建项目指定编码集-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
7.选择YAML或Properties
项目中可以选择YAML和Properties文件做为配置文件(可以同时存在),这里我们统一使用YAML文件,删除原来 resources目录下的application.properties文件,并创建application.yml文件,后缀也可以为yaml:内容如下:
spring:
application:
name: 论坛系统
1.9 测试环境是否正常
(1)打包
(2)测试
1.10 启动程序
(1)编写程序
(2)修改YAML配置文件
spring:
application:
name: 论坛系统 # 项目名称
output:
ansi:
enabled: always # 配置输出的效果
server:
port: 58080 # 自定义的服务端口号
(3)启动
结果:
1.11 访问指定测试接口
1.12 配置日志
spring:
application:
name: 论坛系统 # 项目名称
output:
ansi:
enabled: always # 配置输出的效果
server:
port: 58080 # 自定义的服务端口号
logging:
pattern:
dateformat: MM-dd HH:mm:ss # 日期的显示格式
level:
root: info # 日志的默认级别
com.example.forum: debug # 指定包下的日志级别
file:
path: D:/log/forum #日志保存的路径
1.13 通过Git推送至远程仓库
(1)IDEA中集成了git插件,可以用图形的方式提交代码
(2)可以使用Idea集成的Git完成操作,也可以使用命令行操作并提交,这里使用命令行的方式,在工程根目录下完成如下命令:
#查看当前状态,列出未修改后添加的文件
D:\code\Java\forum> git status
#添加修改后的文件到暂存区,再次运行git status,上面的文件会变为绿色显示
D:\code\Java\forum> git add.
#提交到本地仓库
D:\code\Java\forum>git commit -m
#推送到远程仓库
D:\code\Java\forum> git push
命令行记录:
PS D:\code\Java\forum> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: src/main/java/com/example/forum/controller/TestController.java
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: .gitee/ISSUE_TEMPLATE.zh-CN.md
modified: .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
modified: .gitignore
modified: README.en.md
modified: README.md
modified: src/main/java/com/example/forum/controller/TestController.java
Untracked files:
(use "git add <file>..." to include in what will be committed)
pom.xml
src/main/java/com/example/forum/ForumApplication.java
src/main/resources/
src/test/
PS D:\code\Java\forum> git add.
git: 'add.' is not a git command. See 'git --help'.
The most similar command is
add
PS D:\code\Java\forum> git add .
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in pom.xml.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/java/com/example/forum/ForumApplication.java.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/main/resources/static/index.html.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in src/test/java/com/example/forum/ForumApplicationTests.java.
The file will have its original line endings in your working directory
PS D:\code\Java\forum> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: .gitee/ISSUE_TEMPLATE.zh-CN.md
modified: .gitee/PULL_REQUEST_TEMPLATE.zh-CN.md
modified: .gitignore
modified: README.en.md
modified: README.md
new file: pom.xml
new file: src/main/java/com/example/forum/ForumApplication.java
new file: src/main/java/com/example/forum/controller/TestController.java
new file: src/main/resources/application.yml
new file: src/main/resources/static/index.html
new file: src/test/java/com/example/forum/ForumApplicationTests.java
PS D:\code\Java\forum> git commit -m "第一次提交"
[master ce56851] 第一次提交
11 files changed, 269 insertions(+), 95 deletions(-)
rewrite README.en.md (74%)
rewrite README.md (80%)
create mode 100644 pom.xml
create mode 100644 src/main/java/com/example/forum/ForumApplication.java
create mode 100644 src/main/java/com/example/forum/controller/TestController.java
create mode 100644 src/main/resources/application.yml
create mode 100644 src/main/resources/static/index.html
create mode 100644 src/test/java/com/example/forum/ForumApplicationTests.java
PS D:\code\Java\forum> git push
Enumerating objects: 34, done.
Counting objects: 100% (34/34), done.
Delta compression using up to 16 threads
Compressing objects: 100% (19/19), done.
Writing objects: 100% (28/28), 4.16 KiB | 1.04 MiB/s, done.
Total 28 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag b244be8f
To https://gitee.com/clouds-and-rain-rise/forum.git
699d6f1..ce56851 master -> master
PS D:\code\Java\forum>