springboot 场景启动器使用解析
2020-02-13 13:29
656 查看
这篇文章主要介绍了springboot 场景启动器使用解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
为什么springboot不需要我们去配置那么繁琐的东西?
我们直接看pom.xml
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.gong</groupId> <artifactId>myspringboot</artifactId> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <!--引入springboot的web支持,帮你封装好了很多个依赖--> <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>
首先看spring-boot-starter-parent,spring-boot-start就是场景启动器,这是所有项目的父项目,我们ctrl+鼠标左键点进去:
新文件的开头部分:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.9.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>
它的父项目是spring-boot-dependencies,用于管理依赖包的版本号。也就是说spring-boot-start-parent是版本仲裁中心。
再来看spring-boot-starter-web,我们来查看其中有什么:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starters</artifactId> <version>1.5.9.RELEASE</version> </parent> <artifactId>spring-boot-starter-web</artifactId> <name>Spring Boot Web Starter</name> <description>Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container</description> <url>http://projects.spring.io/spring-boot/</url> <organization> <name>Pivotal Software, Inc.</name> <url>http://www.spring.io</url> </organization> <properties> <main.basedir>${basedir}/../..</main.basedir> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> </dependency> </dependencies> </project>
这里面才是帮我们导入了真正所需的依赖包。
springboot还有许多场景启动器,例如AOP、邮件开发等等。我们只需要在项目里面引用这些starter,这些场景的相关依赖包就会自动导入出来。
以上就是本文的全部内容,希望对大家的学习有所帮助
您可能感兴趣的文章:
相关文章推荐
- springboot 使用hibernate进行双向关联json解析时死循环处理
- Spring Boot 学习4--完美使用FastJson解析Json数据
- (3)spring boot如何使用第三方json解析框架
- SpringBoot2.0 基础案例(05):多个拦截器配置和使用场景
- 78. Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】
- spring boot 源码解析26-Liquibase使用及LiquibaseEndpoint解析
- SpringBoot Profile使用详解及配置源码解析
- Spring Boot使用FastJson解析JSON数据
- springboot中使用redis由浅入深解析
- SpringBoot-Mybatis框架使用与源码解析
- springboot中事务管理@Transactional的注意事项与使用场景
- 使用SpringBoot无法解析jsp的问题
- (4)Spring Boot使用别的json解析框架【从零开始学Spring Boot】
- springboot使用第三方的json解析框架fastjson
- (4)Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】
- Spring Boot 使用第三方json解析 : fastjson
- 学习cassandra(1)入门,使用场景(写多读少)和搭建启动使用,整合Spring boot
- 【spring boot笔记】 springboot 使用第三方json解析
- 【Spring Boot】完美使用FastJson解析JSON数据
- 78. Spring Boot完美使用FastJson解析JSON数据【从零开始学Spring Boot】