Java backend frameworks and common dependencies
Overview of technology stack
| Technical Field | Related Technology | Main Role |
|---|---|---|
| Java Basic Environment | Java 17 | provides a compilation and execution environment for Java backend programs |
| core development framework | Spring Framework | provides basic capabilities such as IoC, DI, AOP, and transaction management |
| Application Development Framework | Spring Boot | simplifies the configuration, dependency management, launch and deployment of Spring applications |
| Web Development | Spring MVC | is responsible for HTTP request processing, parameter binding, controller calls and response data return |
| Data persistence | MyBatis | is responsible for mapping between Java objects and SQL statements |
| Persistence Layer Enhancements | MyBatis-Plus | provides functions such as universal CRUD, condition builder and paging based on MyBatis |
| Relational Database | MySQL | for storing and managing business data |
| Database connection pool | Druid | manages database connections and provides functions such as connection pool monitoring and SQL statistics |
| Security Certification | Spring Security | implements user authentication, rights control and request security management |
| Identity Tokens | JWT, JJWT | Implement token-based stateless identity authentication |
| Interface Documentation | OpenAPI, Knife4j | automatically generate interface documentation, and provide interface viewing and online debugging functions |
| JSON processing | Jackson | completes the conversion between Java objects and JSON data |
| Log Management | SLF4J, Logback, Log4j 2 | Records program running status, debugging information and exception information |
| Code Simplification | Lombok | Reduce duplicate codes such as Getter, Setter, and construction methods through annotations |
| interface design | RESTful | uses HTTP methods and resource path specifications to design backend interface |
| project builds | Maven | manages project dependencies and completes construction tasks such as compilation, testing, and packaging |
| Development Assistant | Spring Boot DevTools | provides development stage assistance functions such as automatic restart |
| Test Support | Spring Boot Test | provides relevant components required for unit and integration testing |
Spring Boot project
Maven project configuration
<?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 https://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>3.3.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.hyxy</groupId>
<artifactId>springboot-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springboot-demo</name>
<description>springboot-demo</description>
<url/>
<licenses>
<license/>
</licenses>
<developers>
<developer/>
</developers>
<scm>
<connection/>
<developerConnection/>
<tag/>
<url/>
</scm>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<!-- Spring MVC、REST Controller、内置 Tomcat -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- 配置提示 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- 热部署 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<!-- SpringBoot3 适配核心依赖 -->
<!-- MyBatisPlus 适配SpringBoot3 专属依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
<version>3.5.6</version>
</dependency>
<!-- MySQL 驱动 -->
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-3-starter</artifactId>
<version>1.2.23</version>
</dependency>
<!-- lombok 简化实体类 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<!-- SpringBoot3 测试依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.12.5</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.12.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.12.5</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
database configuration
Configure MySQL, Druid and MyBatis-Plus in src/main/resources/application.yml.
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid:
url: jdbc:mysql://localhost:33066/java2601?serverTimezone=UTC&characterEncoding=utf8
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
max-active: 10
min-idle: 3
initial-size: 2
max-wait: 10000
mybatis-plus:
# xml映射文件的位置
mapper-locations: classpath*:/mapper/**/*.xml
# 实体类别名 包
type-aliases-package: com.hyxy.mp.entity
configuration:
# 开启下划线转驼峰自动映射
map-underscore-to-camel-case: true
# 开启SQL日志打印
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
# 主键自增策略
id-type: auto
# 数据库表前缀(可选)
# table-pre x: tb_
# 逻辑删除全局配置
# logic-delete-field: deleteFlag
# logic-delete-value: 1 # 已删除
# logic-not-delete-value: 0 # 未删除
# Knife4j 核心配置(SpringBoot3 通用)
knife4j:
# 开启增强模式(解锁全部高级功能,必开)
enable: true
# 生产环境开关(true=生产关闭文档,false=开发开启)
production: false
# UI个性化配置
setting:
# 开启暗黑模式
enable-dark-mode: true
# 开启接口搜索
enable-search: true
# 显示参数长度
enable-param-length: true
# 开启接口显示排序
enable-api-sort: true
jwt:
secret: l06rIAxOHwGDnjGUvN5XhVIyW4PGQzy4Eff+GFwZTA=
expire-ms: 3600000
If you enjoyed this, leave a comment~