2024年1月Java项目开发指南3:创建Springboot项目

发布时间 2024-01-10 15:12:32作者: 萌狼蓝天

本文档编写于贰零贰肆年一月八日@萌狼蓝天

如果你不知道什么是springboot,那么你只需要知道,这是一个让我们减少配置工作量,方便开发的开发框架,能让我们更专心于业务开发,省的被各种各样的配置浪费时间。
至于这框架有啥效果,有啥优点,有啥缺点,用过就知道了!

软件:IDEA2023.2.3

创建项目

image-20240108233004658

image-20240108233106380

image-20240108233150744

image-20240108233212660

image-20240108233243593

上述选择仅供参考,具体根据自己的需要来选择

编写基本配置

配置文件写法有很多,根据自己需要和自己喜欢的格式来即可

# Project Info Setting

application.title=便利店管理系统
application.name=server-system
application.version=1.0.0
# Server Info Setting
server.port=8080
server.servlet.context-path=/
server.servlet.session.timeout=3600
# Spring Boot Info Setting
## 设置横幅作为日志方式打印
spring.main.banner-mode=log
spring.banner.charset=utf-8
spring.banner.location=classpath:banner.txt
# MySQL Setting
spring.datasource.url=jdbc:mysql://localhost:3306/server-system?serverTimezone=UTC&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# MyBatis Setting
mybatis.type-aliases-package=com.server.system.domain
mybatis.mapper-locations=classpath:mapper/*.xml

设置了个banner


██╗  ██╗██████╗ ██╗██╗      █████╗ ███╗   ██╗ ██████╗
╚██╗██╔╝██╔══██╗██║██║     ██╔══██╗████╗  ██║██╔════╝
 ╚███╔╝ ██████╔╝██║██║     ███████║██╔██╗ ██║██║  ███╗
 ██╔██╗ ██╔══██╗██║██║     ██╔══██║██║╚██╗██║██║   ██║
██╔╝ ██╗██║  ██║██║███████╗██║  ██║██║ ╚████║╚██████╔╝
╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝ ╚═════╝

^_^ 服务启动成功 ${application.title}
# 项目名称:${application.name}
# 项目版本:${application.version}
# 框架版本:${spring-boot.version}
# 最后更新于 2024年 1月 9日

image-20240109175415220

运行效果

image-20240109175435677

然后在resources文件夹的static文件夹内创建文件index,作为默认启动页面

image-20240109175628262