欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 财经 > 创投人物 > Spring Boot 常用依赖介绍

Spring Boot 常用依赖介绍

2025/4/17 23:17:57 来源:https://blog.csdn.net/m0_46565230/article/details/147079926  浏览:    关键词:Spring Boot 常用依赖介绍

依赖总括

1. 核心依赖:Spring Web、Spring Data JPA、MySQL Driver。
 2. 开发工具:Lombok、Spring Boot DevTools。
 3. 安全与权限:Spring Security。
 4. 测试与文档:Spring Boot Starter Test、Swagger。
 5. 性能优化:Spring Boot Starter Cache、Redis。
 6. 监控与管理:Spring Boot Starter Actuator。

spring-boot-starter-parent

springboot项目的总(父)依赖,主要负责版本管理

<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.4.4</version><relativePath/> <!-- lookup parent from repository --></parent>

当我们使用 spring 或 spring-boot 开发项目时,需要引入很多依赖,包括 spring 本身的组件、各种 spring-boot-starter、以及其它第三方依赖(如:slf4j、redis)。依赖多了,版本的选择是个问题,就怕哪个版本选择的不对导致出现一些意想不到的 BUG。
spring-boot-dependencies的作用主要是起到约束版本的作用,在这个包里面声明了各种版本号。如果当下面的< dependency >中用到就可以不用配置版本号< version >

spring-boot-starter-web

可执行的 Web 应用且内含SpringBoot核心启动器,包含各种springboot的配置日志等,创建项目时会自动引入该依赖

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
spring-boot-starter-web 中包含了 spring-boot-starter等,所以就不需要再配置 spring-boot-starter 依赖

spring-boot-starter支持注解:@controller、@Service、@Component、@Resource 是spring的,所以spring boot创建完成后就可以使用
spring-boot-starter-web支持注解:@RestController、@RequestMapping、@ResponseBody、@JsonFormat

mybatis-plus-boot-starter

spring-boot-starter-jdbc

druid-spring-boot-3-starter

mysql-connector-java

lombok

@Data 注解,自动生成Getter、Setter、构造函数等代码

@Slf4j 注解,不需要单独引入日志依赖和配置日志,直接 log.info( ) 打印日志

<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.28</version></dependency>

spring-boot-starter-aop

面向切面编程AOP

@AspectJ、@Pointcut,@Before、@After等,@Aspect和自定义注解

spring-boot-starter-test

用于编写springboot Test测试类

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>

spring-boot-devtools

springboot热部署,修改java代码后,不用重启项目就能直接最新测试,省略了不断修改代码不断重启项目的麻烦

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><optional>true</optional>
</dependency>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词