- Maven项目搭建
- 新建maven工程
- 目录与名称
- 检查编码、maven仓库配置、jdk配置
- 添加xml依赖、继承Springboot父类(2.5.4)
- yml文件
- 编写启动类
- 测试通过
- 导入前端页面
- backend(后端后台功能页面)
- front(前端面板页面)
- 配置mvc框架的静态资源映射
- 新建WebMvcConfig.java
- 编写ReggieApplication.java入口
- 启动测试成功
- 上传git成功(使用idea上传)
maven
添加xml依赖、继承Springboot父类(2.5.4)jdk
yml文件4.0.0 org.springframework.boot spring-boot-starter-parent 2.5.4 com.taotao reggie_take_out 1.0-SNAPSHOT 1.8 org.springframework.boot spring-boot-starter org.springframework.boot spring-boot-starter-test test org.springframework.boot spring-boot-starter-web compile com.baomidou mybatis-plus-boot-starter 3.4.2 org.projectlombok lombok 1.18.20 com.alibaba fastjson 1.2.76 commons-lang commons-lang 2.6 mysql mysql-connector-java runtime com.alibaba druid-spring-boot-starter 1.1.23 org.springframework.boot spring-boot-maven-plugin 2.4.5
server:
port: 8080
spring:
application:
name: reggie_take_out
datasource:
druid:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/reggie?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 12345
mybatis-plus:
configuration:
# mybatis-plus自动映射
# address_book--->AddressBook
# user_name---->userName
#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: ASSIGN_ID
编写启动类
package com.taotao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SuppressWarnings({"all"})
@Slf4j
@SpringBootApplication
public class reggie {
public static void main(String[] args) {
log.info("项目启动成功");
}
}
测试通过
导入前端页面
- 直接复制黏贴黑马的资料
配置mvc框架的静态资源映射此时我们虽然已经复制过来了页面,但是启动项目后依然不能正常访问,因为我们没有放在static目录下(静态资源映射)
- 目的就是加载访问前端页面
- 当然你也可以把前端页面放入到static目录下,只是不建议如此而已
package com.taotao.reggie.config;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
@SuppressWarnings({"all"})
//此注解用于记录日志,方便调试
@Slf4j
//Configuration注解说明了这是一个配置类
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
log.info("开始静态资源映射...");
registry.addResourceHandler("/backend
@SuppressWarnings({"all"})
@Slf4j
@SpringBootApplication
public class ReggieApplication {
public static void main(String[] args) {
SpringApplication.run(ReggieApplication.class,args);
log.info("项目启动成功");
}
}
启动测试成功
上传git成功(使用idea上传)



