当前位置:   article > 正文

springboot项目需要的依赖_建立一个快速的springboot微服务,核心依赖是什么

建立一个快速的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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/813207
推荐阅读
相关标签
  

闽ICP备14008679号