springboot 場(chǎng)景啟動(dòng)器使用解析
這篇文章主要介紹了springboot 場(chǎng)景啟動(dòng)器使用解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
為什么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支持,幫你封裝好了很多個(gè)依賴--> <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就是場(chǎng)景啟動(dòng)器,這是所有項(xiàng)目的父項(xiàng)目,我們ctrl+鼠標(biāo)左鍵點(diǎn)進(jìn)去:
新文件的開頭部分:
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.9.RELEASE</version> <relativePath>../../spring-boot-dependencies</relativePath> </parent>
它的父項(xiàng)目是spring-boot-dependencies,用于管理依賴包的版本號(hào)。也就是說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>
這里面才是幫我們導(dǎo)入了真正所需的依賴包。
springboot還有許多場(chǎng)景啟動(dòng)器,例如AOP、郵件開發(fā)等等。我們只需要在項(xiàng)目里面引用這些starter,這些場(chǎng)景的相關(guān)依賴包就會(huì)自動(dòng)導(dǎo)入出來。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
淺談Java異常的Exception e中的egetMessage()和toString()方法的區(qū)別
下面小編就為大家?guī)硪黄獪\談Java異常的Exception e中的egetMessage()和toString()方法的區(qū)別。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-07-07學(xué)Java做項(xiàng)目需要學(xué)習(xí)的一些技能
這篇文章主要介紹了學(xué)Java做項(xiàng)目需要學(xué)習(xí)的一些技能,例如JavaSE、Servlet、JSP等,總結(jié)了他們中需要學(xué)習(xí)的東西,都是一些經(jīng)驗(yàn)總結(jié),需要的朋友可以參考下2014-07-07Java MD5消息摘要算法原理及實(shí)現(xiàn)代碼
這篇文章主要介紹了Java MD5消息摘要算法原理及實(shí)現(xiàn)代碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09SpringBoot集成Spring Security用JWT令牌實(shí)現(xiàn)登錄和鑒權(quán)的方法
這篇文章主要介紹了SpringBoot集成Spring Security用JWT令牌實(shí)現(xiàn)登錄和鑒權(quán)的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-05-05springboot中使用Feign整合nacos,gateway進(jìn)行微服務(wù)之間的調(diào)用方法
這篇文章主要介紹了springboot中使用Feign整合nacos,gateway進(jìn)行微服務(wù)之間的調(diào)用方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-03-03springboot整合dubbo設(shè)置全局唯一ID進(jìn)行日志追蹤的示例代碼
這篇文章主要介紹了springboot整合dubbo設(shè)置全局唯一ID進(jìn)行日志追蹤,本文通過圖文示例相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-10-10Java8實(shí)現(xiàn)FTP及SFTP文件上傳下載
這篇文章主要介紹了Java8實(shí)現(xiàn)FTP及SFTP文件上傳下載,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-09-09Java基礎(chǔ)知識(shí)之I/O流和File類文件操作
眾所周知java語言提供給程序員非常多的包供編程時(shí)使用,方便又快捷,下面這篇文章主要給大家介紹了關(guān)于Java基礎(chǔ)知識(shí)之I/O流和File類文件操作的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-04-04