springboot第8集:示例代码案例详细解释内容

controller.TestController

@RestController // 将数据以json形式返回
public classTestController {
 @GetMapping("/test")
 public String test() {
  return "hello "
 }
}

集成热部署并配置多环境和sql日志

springboot第8集:示例代码案例详细解释内容_第1张图片 1679721134006.png springboot第8集:示例代码案例详细解释内容_第2张图片 1679721175446.png springboot第8集:示例代码案例详细解释内容_第3张图片 1679721228189.png springboot第8集:示例代码案例详细解释内容_第4张图片 1679721268842.png springboot第8集:示例代码案例详细解释内容_第5张图片 1679721332998.png springboot第8集:示例代码案例详细解释内容_第6张图片 1679721419897.png

创建数据库以及表

springboot第8集:示例代码案例详细解释内容_第7张图片 1679721895855.png springboot第8集:示例代码案例详细解释内容_第8张图片 image.png springboot第8集:示例代码案例详细解释内容_第9张图片 image.png springboot第8集:示例代码案例详细解释内容_第10张图片 image.png springboot第8集:示例代码案例详细解释内容_第11张图片 image.png
  • 点击【终端】,登录root帐号,根据系统运行命令安装maven。

apt-get install maven

或者

yum install maven

解压到宝塔面板/www/wwwroot目录。

springboot第8集:示例代码案例详细解释内容_第12张图片 image.png

打开【终端】,运行cd命令进入项目目录的server目录,运行编译命令。首次编译需要下载依赖,时间会比较长。

cd /www/wwwroot/xxx/server
mvn clean install -Dmaven.test.skip=true -f pom.xml
springboot第8集:示例代码案例详细解释内容_第13张图片 image.png springboot第8集:示例代码案例详细解释内容_第14张图片 image.png

点击【设置】-【伪静态】,填写下面伪静态信息,【保存】。

location / {
  try_files $uri $uri/ /index.html;
}
springboot第8集:示例代码案例详细解释内容_第15张图片 image.png

点击【SSL】-【Let's Encrypt】,选择【文件验证】,勾选域名,点击【申请】,等待完成https证书申请。

springboot第8集:示例代码案例详细解释内容_第16张图片 image.png springboot第8集:示例代码案例详细解释内容_第17张图片 image.png

PC端和手机端

# 请将伪静态规则或自定义NGINX配置填写到此
location /pc {
  try_files $uri $uri/ /pc/index.html;
}

location /mobile {
  try_files $uri $uri/ /mobile/index.html;
}

点击【SSL】-【Let's Encrypt】,选择【文件验证】,勾选域名,点击【申请】,等待完成https证书申请。

如果该产品有PC端网页前台访问:https://添加的前台域名/pc,即可访问PC端。如果该产品有手机网页端前台访问:https://添加的前台域名/mobile,即可访问PC端。默认访问域名,会自动根据访问者使用PC或手机自动跳转。

仓库地址:https://github.com/webVueBlog/JavaGuideInterview

你可能感兴趣的:(spring,boot,java,数据库,后端,spring)