当前位置:网站首页>启动项目(瑞吉外卖)
启动项目(瑞吉外卖)
2022-08-04 17:17:00 【不会压弯的小飞侠】
博客主页:@不会压弯的小飞侠欢迎关注:点赞收藏留言系列专栏:瑞吉外卖知足上进,不负野心。欢迎大佬指正,一起学习!一起加油!

继承Springboot父类,添加xml依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.xfx</groupId>
<artifactId>reggie_take_out</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.76</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.23</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.5</version>
</plugin>
</plugins>
</build>
</project>
配置yml文件
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: root
mybatis-plus:
configuration:
#在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
id-type: ASSIGN_ID
注意:
spring:
application:
name: reggie_take_out
这部分可以省略不写,应用的名称默认项目名称,你也可以更改项目名称。
map-underscore-to-camel-case: true
在映射实体或者属性时,将数据库中表名和字段名中的下划线去掉,按照驼峰命名法映射 例如user_name--->userName
编写启动类
package com.jkj.reggie;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@Slf4j
@SpringBootApplication
public class ReggieApplication {
public static void main(String[] args) {
SpringApplication.run(ReggieApplication.class,args);
log.info("项目启动成功!");
}
}
导入前端页面
把这两个文件直接粘贴在resource下(后续会把资源放到GitHub中,需要自取)
- backend(后端后台功能页面)
- front(前端面板页面)
配置mvc框架的静态资源映射
前端页面没有放到static目录下,配置mvc框架的静态资源映射就是为了加载访问前端页面。
在config包下创建MVC拦截器
package com.jkj.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;
@Slf4j
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
/** * 设置静态资源映射 * @param registry */
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
log.info("开始静态资源映射......");
registry.addResourceHandler("/backend/**").addResourceLocations("classpath:/backend/");
registry.addResourceHandler("/front/**").addResourceLocations("classpath:/front/");
}
}
启动项目
报错可以忽略,因为后端还没做。

边栏推荐
- 吃透Chisel语言.32.Chisel进阶之硬件生成器(一)——Chisel中的参数化
- 【LeetCode每日一题】——374.猜数字大小
- R语言使用ggpubr包的ggsummarystats函数可视化柱状图(通过ggfunc参数设置)、在可视化图像的下方添加描述性统计结果表格、palette参数配置柱状图及统计数据的颜色
- 动态数组底层是如何实现的
- init和destory方法
- Unity Apple登录接入
- 域名哪家便宜?怎么买便宜域名?
- R语言使用yardstick包的gain_curve函数评估多分类(Multiclass)模型的性能、查看模型在多分类每个分类上的增益(gain)曲线(gain curve)
- 如何模拟后台API调用场景,很细!
- response的contentType 几种类型
猜你喜欢

WEB 渗透之越权

【LeetCode Daily Question】——374. Guess the size of the number

餐饮供应链管理系统

Codeforces Round #811 (Div. 3)

要有遥不可及的梦想,也要有脚踏实地的本事

Learning to Explore - Setting the Foreground Color for Fonts

88.(cesium之家)cesium聚合图

LeetCode Question of the Day - 1403. Minimum Subsequence in Non-Increasing Order

Nacos集群搭建

8月5日,麒麟信安邀您相约鲲鹏开发者创享日·长沙站!
随机推荐
租房小程序登顶码云热门
R语言ggplot2可视化:使用ggpubr包的ggbarplot函数可视化柱状图、color参数指定柱状图的边框的色彩
To eliminate asynchronous callbacks, it has to be async-await
学习探索-给字体设置前景色
44. 通配符匹配 ●●● & HJ71 字符串通配符 ●●
御神楽的学习记录之基于FPGA的AHT10温湿度数据采集
Digital-intelligent supply chain management system for chemical manufacturing industry: build a smart supply system and empower enterprises to improve production efficiency
Learning and Exploration-Introducing Baidu Statistics to the Website
R语言缺失时间序列的填充及合并:补齐时间序列数据中所有缺失的时间索引、使用merge函数合并日期补齐之后的时间序列数据和另外一个时间序列数据(补齐左侧数据)
icu是哪个国家的域名?icu是什么域名?
海报 | 夏季高温,危化品安全风险的注意事项必须get!
如何模拟后台API调用场景,很细!
机器学习(十四):K均值聚类(kmeans)
从云计算到函数计算
php如何查询字符串以什么开头
太一集团全资收购火币旗下社交产品火信
GraphQL 入门与实践
集群监控——Zabbix使用
Kotlin挂起函数原理是什么
shell函数内如何调用另一个函数
