RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
springboot场景启动器使用解析

这篇文章主要介绍了springboot 场景启动器使用解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

我们提供的服务有:网站建设、做网站、微信公众号开发、网站优化、网站认证、禹王台ssl等。为近1000家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的禹王台网站制作公司

为什么springboot不需要我们去配置那么繁琐的东西?

我们直接看pom.xml

<?xml version="1.0" encoding="UTF-8"?>

  4.0.0

  com.gong
  myspringboot
  1.0-SNAPSHOT
  
    org.springframework.boot
    spring-boot-starter-parent
    1.5.9.RELEASE
  

  
    
    
      org.springframework.boot
      spring-boot-starter-web
    
  
  
    
      
        org.springframework.boot
        spring-boot-maven-plugin
      
    
  

首先看spring-boot-starter-parent,spring-boot-start就是场景启动器,这是所有项目的父项目,我们ctrl+鼠标左键点进去:

新文件的开头部分:


    org.springframework.boot
    spring-boot-dependencies
    1.5.9.RELEASE
    ../../spring-boot-dependencies
  

它的父项目是spring-boot-dependencies,用于管理依赖包的版本号。也就是说spring-boot-start-parent是版本仲裁中心。

再来看spring-boot-starter-web,我们来查看其中有什么:

<?xml version="1.0" encoding="UTF-8"?>

  4.0.0
  
    org.springframework.boot
    spring-boot-starters
    1.5.9.RELEASE
  
  spring-boot-starter-web
  Spring Boot Web Starter
  Starter for building web, including RESTful, applications using Spring
    MVC. Uses Tomcat as the default embedded container
  http://projects.spring.io/spring-boot/
  
    Pivotal Software, Inc.
    http://www.spring.io
  
  
    ${basedir}/../..
  
  
    
      org.springframework.boot
      spring-boot-starter
    
    
      org.springframework.boot
      spring-boot-starter-tomcat
    
    
      org.hibernate
      hibernate-validator
    
    
      com.fasterxml.jackson.core
      jackson-databind
    
    
      org.springframework
      spring-web
    
    
      org.springframework
      spring-webmvc
    
  

这里面才是帮我们导入了真正所需的依赖包。

springboot还有许多场景启动器,例如AOP、邮件开发等等。我们只需要在项目里面引用这些starter,这些场景的相关依赖包就会自动导入出来。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。


当前标题:springboot场景启动器使用解析
本文URL:http://scyingshan.cn/article/jchjhj.html