SpringBoot工程的三種搭建方式分別是什么,針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
為太白等地區(qū)用戶提供了全套網(wǎng)頁設計制作服務,及太白網(wǎng)站建設行業(yè)解決方案。主營業(yè)務為成都網(wǎng)站設計、成都做網(wǎng)站、太白網(wǎng)站設計,以傳統(tǒng)方式定制建設網(wǎng)站,并提供域名空間備案等一條龍服務,秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!
SpringBoot的主要目的是簡化配置文件,通過少量配置即可運行Java程序,其強大的自動配置功能幫助開發(fā)者輕松實現(xiàn)配置裝配,通過引入SpringBoot的 starter
就能實現(xiàn)想要的功能,不需要額外的配置。
目前SpringBoot工程有三種搭建方式:
通過Spring Initializr創(chuàng)建 通過IDEA創(chuàng)建工程 手動創(chuàng)建工程
官方生成工具
Spring團隊提供一個非常方便的網(wǎng)頁用于生成SpringBoot工程,打開瀏覽器進入Spring Initializr:
工程生成參數(shù)列表:
Project: 工程類型(支持Maven和Gradle構(gòu)建工具) Language:工程主要語言根據(jù)需要可選擇Java、Kotlin、Groovy SpringBoot:SpringBoot版本 ProjectMatedata:有 Group
和 Artifact
等配置 Dependencies:工程依賴
參數(shù)設置完成后點擊 Generate
下載工程,完成后使用 IDEA
導入工程,打開工程同步即可運行。
IDEA創(chuàng)建工程
較新的 IDEA
版本都內(nèi)置創(chuàng)建SpringBoot工程插件,其創(chuàng)建原理也是使用的Spring Initializr來創(chuàng)建工程,創(chuàng)建流程下如:
打開 IDEA
開發(fā)工具 選擇 file
-> new
-> project
菜單 在新的對話框中選擇 Spring Initializr
點擊 Next
即可創(chuàng)建SpringBoot工程
最后添加 main
方法啟動應用程序:
@SpringBootApplication@Slf4jpublic class SpringEnvApplication { public static void main(String[] args) { ConfigurableApplicationContext context = SpringApplication.run(SpringEnvApplication.class, args); }}
手動創(chuàng)建SpringBoot工程
除了以上兩種方式外,還可以通過手動創(chuàng)建的方式創(chuàng)建SpringBoot工程,通過 IDEA
創(chuàng)建一個空的 Maven
工程,然后指定SpringBoot的依賴就,基本流程如下:
打開 IDEA
開發(fā)工具 選擇 file
-> new
-> project
菜單 在新的對話框中選擇 Mavenn
點擊 Next
根據(jù)提示完成項目創(chuàng)建
工程創(chuàng)建完成后,打開 pom.xml
文件,設置 pom.xml
的parent配置:
<parent> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <version>2.2.0.RELEASE</version></parent>
添加SpringBoot Maven
打包插件:
<build> <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugins></build>
添加 main
方法啟動應用程序:
@SpringBootApplication@Slf4jpublic class SpringEnvApplication { public static void main(String[] args) { ConfigurableApplicationContext context = SpringApplication.run(SpringEnvApplication.class, args); }}
完整 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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <groupId>com.csbaic.arch</groupId>
<artifactId>spring-env</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-env</name>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build></project>
設置parent和插件后,就可以使用SpringBoot創(chuàng)建應用程序了。
關(guān)于SpringBoot工程的三種搭建方式分別是什么問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。
網(wǎng)頁題目:SpringBoot工程的三種搭建方式分別是什么
當前網(wǎng)址:http://chinadenli.net/article22/jeigcc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、微信公眾號、網(wǎng)頁設計公司、Google、做網(wǎng)站、網(wǎng)站導航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)