Sakura-Boot-Demo 项目教程
sakura-boot-demo sakura-boot脚手架的演示工程 项目地址: https://gitcode.com/gh_mirrors/sa/sakura-boot-demo
1. 项目的目录结构及介绍
Sakura-Boot-Demo 项目的目录结构如下:
sakura-boot-demo
├── docs
├── dynamic-cron
├── es
├── fastdfs
├── gateway
├── jpa
├── message
├── minio
├── netty
├── oauth2-demo
├── rabbitmq
├── redis
├── sa-token
├── seata
├── uid-generator
├── web-demo
├── web-socket
├── .gitignore
├── gitlab-ci.yml
├── LICENSE
├── README.md
├── pom.xml
目录结构介绍
- docs: 项目文档目录,包含项目的相关文档。
- dynamic-cron: 动态定时任务示例模块。
- es: Elasticsearch 通用查询示例模块。
- fastdfs: FastDFS 文件上传下载示例模块。
- gateway: SpringCloud Gateway 网关模块。
- jpa: JPA + QueryDSL 常见的 CRUD 示例模块。
- message: 消息发送模块,包含邮件发送示例。
- minio: MinIO 文件上传示例模块。
- netty: Netty 传输大文件、分片发送、断点续传示例模块。
- oauth2-demo: OAuth2 认证服务模块。
- rabbitmq: RabbitMQ 工具类生产消费示例模块。
- redis: Redis 工具类示例模块。
- sa-token: SaToken 认证示例模块。
- seata: Seata 分布式事务示例模块。
- uid-generator: 分布式 ID 生成器示例模块。
- web-demo: 基于 MybatisPlus 的 ORM 框架,常见的 Web 开发示例模块。
- web-socket: WebSocket 广播单播使用示例模块。
- .gitignore: Git 忽略文件配置。
- gitlab-ci.yml: GitLab CI/CD 配置文件。
- LICENSE: 项目许可证文件。
- README.md: 项目说明文档。
- pom.xml: Maven 项目配置文件。
2. 项目的启动文件介绍
项目的启动文件主要位于各个模块的 src/main/java
目录下,通常包含一个主启动类,例如 WebDemoApplication.java
。以下是一个典型的启动类示例:
package com.example.webdemo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class WebDemoApplication {
public static void main(String[] args) {
SpringApplication.run(WebDemoApplication.class, args);
}
}
启动类介绍
- @SpringBootApplication: 这是一个组合注解,包含了
@Configuration
、@EnableAutoConfiguration
和@ComponentScan
,用于自动配置 Spring Boot 应用程序。 - SpringApplication.run(): 启动 Spring Boot 应用程序。
3. 项目的配置文件介绍
项目的配置文件主要位于 src/main/resources
目录下,常见的配置文件包括 application.yml
或 application.properties
。以下是一个典型的 application.yml
配置文件示例:
spring:
datasource:
url: jdbc:mysql://localhost:3306/sakura
username: root
password: admin
redis:
host: localhost
port: 6379
rabbitmq:
host: localhost
port: 5672
username: guest
password: guest
server:
port: 8080
logging:
level:
root: INFO
配置文件介绍
- spring.datasource: 配置数据库连接信息,包括 URL、用户名和密码。
- spring.redis: 配置 Redis 连接信息,包括主机和端口。
- spring.rabbitmq: 配置 RabbitMQ 连接信息,包括主机、端口、用户名和密码。
- server.port: 配置应用程序的启动端口。
- logging.level: 配置日志级别。
通过以上配置,可以启动并运行 Sakura-Boot-Demo 项目,并根据需要进行相应的调整和扩展。
sakura-boot-demo sakura-boot脚手架的演示工程 项目地址: https://gitcode.com/gh_mirrors/sa/sakura-boot-demo