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

篇章三 论坛系统——环境搭建

目录

1.搭建环境

1.1 检查JDK

1.2 检查MySQL数据库

1.3 检查 Maven

1. 部署方式

2. 安装步骤

2.1 从官网下载-个Maven 3.8.X

2.2 配置Maven的环境变量

2.3 配置国内的镜像

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.8 调整项目配置

1.maven配置

1.1 报错:maven打包的时候出现 JDK 无效

2.编码配置

3.代码补全配置

4.自动导包配置

5. 开启热部署

6.JDK版本配置

7.选择YAML或Properties

1.9 测试环境是否正常

1.10 启动程序

1.11 访问指定测试接口

1.12 配置日志

1.13 通过Git推送至远程仓库


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.javaChanges 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.mdmodified:   .gitee/PULL_REQUEST_TEMPLATE.zh-CN.mdmodified:   .gitignoremodified:   README.en.mdmodified:   README.mdmodified:   src/main/java/com/example/forum/controller/TestController.javaUntracked files:(use "git add <file>..." to include in what will be committed)pom.xmlsrc/main/java/com/example/forum/ForumApplication.javasrc/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 isadd
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.mdmodified:   .gitee/PULL_REQUEST_TEMPLATE.zh-CN.mdmodified:   .gitignoremodified:   README.en.mdmodified:   README.mdnew file:   pom.xmlnew file:   src/main/java/com/example/forum/ForumApplication.javanew file:   src/main/java/com/example/forum/controller/TestController.javanew file:   src/main/resources/application.ymlnew file:   src/main/resources/static/index.htmlnew file:   src/test/java/com/example/forum/ForumApplicationTests.javaPS 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.xmlcreate mode 100644 src/main/java/com/example/forum/ForumApplication.javacreate mode 100644 src/main/java/com/example/forum/controller/TestController.javacreate mode 100644 src/main/resources/application.ymlcreate mode 100644 src/main/resources/static/index.htmlcreate 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.git699d6f1..ce56851  master -> master
PS D:\code\Java\forum> 

http://www.xdnf.cn/news/961885.html

相关文章:

  • 如何将数据从 iPhone 传输到笔记本电脑
  • ACM70V-701-2PL-TL00
  • CPP基础(2)
  • Linux 删除登录痕迹
  • rapidocr v3.1.0发布
  • 什么样的登录方式才是最安全的?
  • 高频交易技术:订单簿分析与低延迟架构——从Level 2数据挖掘到FPGA硬件加速的全链路解决方案
  • Numpy7——数学2(矩阵基础,线性方程基础)
  • 看板会议如何高效进行
  • 设计模式和设计原则回顾
  • React动态渲染:如何用map循环渲染一个列表(List)
  • VsCode 离线插件下载
  • 第十三章 RTC 实时时钟
  • 从离散控制到集成管理:Modbus TCP转CANopen网关重构烟丝膨胀生产线
  • 如何使用 IP 地址修改 Android 的 Captive Portal 校验 URL
  • 关于Android camera2预览变形的坑
  • 《高等数学》(同济大学·第7版)第四章第二节换元积分法
  • 在GIS 工作流中实现数据处理
  • 天机学堂手撸
  • CentOS下的分布式内存计算Spark环境部署
  • 什么是MongoDB
  • freeCAD 学习 step1
  • 【FFmpeg学习(2)】视频概念
  • 雨季智慧交通:从车辆盲区到客流统计的算法全覆盖
  • ubuntu + nginx 1.26 + php7.4 + mysql8.0 调优
  • Cypher 查询语言完全指南(2024最新版)—— Neo4j 图数据库实战教程
  • Unity | AmplifyShaderEditor插件基础(第八集:噪声波动shader)
  • QT中实现tcp连接
  • MongoDB数据库应用
  • AO810 AO810V2 - ABB Ability系统800xA硬件