• springboot项目需要的依赖


    springboot项目必不可少的依赖及其作用

    springboot项目需要的依赖

    1. 我们在创建springboot项目时候会发现每个新建的springboot项目都有一个父依赖。

      org.springframework.boot spring-boot-starter-parent 1.4.0.RELEASE
    2. 每个springboot-web项目都有web依赖

      org.springframework.boot spring-boot-starter-web
    3. 总结

      1. 首先springboot的核心就是starter模块核心依赖和autoconfiguration自动配置
         starter:每个spring框架都有与之对应的starter,如springmvc有spring-boot-starter-web,spring-boot-starter-web 内置web容
      			器tomcat等
         autoconfiguration:自动化配置为springboot项目简化了繁琐的配置文件;核心就是通过@SpringBootApplication继承了
         					  @SpringbootConfiguration和@EnableAutoConfiguration还有@ComponentScan这三个注解;可以通过
         					  spring-boot-autoconfiguration-1.2.*.RELEASE.jar里面的spring-configuration-metadata.json看到所有当前
         					  starter(框架)下面所有定义的配置属性。						
      2. spring-boot-starter-parent是一个springboot项目的父工程,它定义了很多当前项目的规范,比如:
      		a:定义了Java编译版本为 1.8.
      		b:使用UTF-8格式编码。
      		c:继承自spring-boot-dependencies,这个里面定义了依赖的版本,也是因为继承了这个依赖,我们在写依赖时才不需要写版本号。
      		d:执行打包操作的配置。
      		e:自动化的资源过滤。
      		f: 自动化的插件配置。
      		g:针对 application.properties 和application.yml 的资源过滤,包括通过profile定义不同的环境配置文件,application-dev.properties 和application-pro.properties.
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
      1. 所以一般的maven父pom工程可能会继承spring-boot-dependencies



        org.springframework.boot
        spring-boot-dependencies
        2.1.4.RELEASE
        pom
        import


      这样虽然以来的版本号问题解决了,但是唯独parent依赖解决的那些打包插件配置,编译的jdk版本,文件编码格式等等这些配置,在没有parent的时候,都需要自己再去配置。这就是parent依赖的重要作用。
      
      • 1
  • 相关阅读:
    Java中常见锁的分类及概念分析
    MySQL 中的 CASE WHEN 和功能类似的方法
    基于SSM的社区文化宣传网站
    类与对象(中篇)
    使用vite 搭建vue 3的项目
    mysql-集群-二进制部署
    如何成为一个Android大厂「offer收割机」, 提炼神功的秘籍在此
    数据库-数据定义和操纵-DML语言的使用
    Lambda表达式,Stream流
    5、Spring cloud注册中心之zookeeper
  • 原文地址:https://blog.csdn.net/m0_67402235/article/details/126516147