springboot 場景啟動器使用解析
這篇文章主要介紹了springboot 場景啟動器使用解析,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下
為什么springboot不需要我們?nèi)ヅ渲媚敲捶爆嵉臇|西?
我們直接看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、郵件開發(fā)等等。我們只需要在項目里面引用這些starter,這些場景的相關依賴包就會自動導入出來。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
淺談Java異常的Exception e中的egetMessage()和toString()方法的區(qū)別
下面小編就為大家?guī)硪黄獪\談Java異常的Exception e中的egetMessage()和toString()方法的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-07-07SpringBoot集成Spring Security用JWT令牌實現(xiàn)登錄和鑒權(quán)的方法
這篇文章主要介紹了SpringBoot集成Spring Security用JWT令牌實現(xiàn)登錄和鑒權(quán)的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-05-05springboot中使用Feign整合nacos,gateway進行微服務之間的調(diào)用方法
這篇文章主要介紹了springboot中使用Feign整合nacos,gateway進行微服務之間的調(diào)用方法,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-03-03springboot整合dubbo設置全局唯一ID進行日志追蹤的示例代碼
這篇文章主要介紹了springboot整合dubbo設置全局唯一ID進行日志追蹤,本文通過圖文示例相結(jié)合給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-10-10