开发环境:
IDEA,MySQL,Navicat(数据库可视化)
一、前端服务搭建
新建一个用于存储项目的文件夹
cmd中切换到该文件夹位置(或直接在该文件夹中右键选择在终端中打开)
依次运行下面代码
npm install -g @vue/cli
vue create vue
选择最后一项(通过上下键)后回车
通过空格键选择需要安装的组件
选择版本号
输入y
选择package.json
输入y
保存的名字:babal-route
创建完成,依次输入提示的两行命令
创建成功,尝试在浏览器访问 localhost:8080
前端创建完成,在IDEA中直接打开该项目(可以直接把这个文件夹拖进IDEA),选择编辑配置
配置
配置完成后可直接在IDEA中运行
二、后台服务搭建
选择组件
刷新Maven,等待导入完成
最后在springbooot/main/resources/application.yml中配置连接数据库
server:
port: 9090
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2b8 # ????
username: root
password: 123456
在SpringbootApplication中写一个接口测试
package com.example.springboot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class SpringbootApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
@GetMapping
public String health(){
return "success";
}
}
运行后在浏览器中访问 localhost:9090