怎么在idea中創(chuàng)建SpringBoot項(xiàng)目-創(chuàng)新互聯(lián)

這篇文章將為大家詳細(xì)講解有關(guān)怎么在idea中創(chuàng)建Spring Boot項(xiàng)目,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。

10年的牧野網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都營銷網(wǎng)站建設(shè)的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整牧野建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“牧野網(wǎng)站設(shè)計(jì)”,“牧野網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

 一、操作步驟

①使用idea新建一個(gè)Spring Boot項(xiàng)目

②修改pom.xml

③修改application.properties

④修改編寫一個(gè)Hello Spring Boot的Controller

⑤啟動(dòng)項(xiàng)目訪問

二、詳細(xì)步驟

1、File-->New-->Project

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

2、選擇Spring Initializr 然后Next

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

3、輸入Artiface 然后Next

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

4、勾選Web 、模版我們選擇官方推薦的Thymeleaf模版引擎,其他框架、中間件、數(shù)據(jù)庫根據(jù)需要選擇即可,而且無需我們手動(dòng)去添加配置文件等,選擇完成后Next

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

選擇模版引擎

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

5、Finish即可

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

6、查看Spring Boot項(xiàng)目結(jié)構(gòu)目錄

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

7、在pom.xml添加如下內(nèi)容

注意:如果新建項(xiàng)目時(shí)選擇了依賴的mybatis、mongodb之類的啟動(dòng)時(shí)候會(huì)報(bào)錯(cuò),由于沒配置數(shù)據(jù)源及mongodb的連接信息,此時(shí)如果只是想測試項(xiàng)目是否搭建成功先注釋即可

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>
 
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
  </properties>
 
  <dependencies>
    <!--<dependency>-->
      <!--<groupId>org.springframework.boot</groupId>-->
      <!--<artifactId>spring-boot-starter-data-mongodb</artifactId>-->
    <!--</dependency>-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <!--<dependency>-->
      <!--<groupId>org.mybatis.spring.boot</groupId>-->
      <!--<artifactId>mybatis-spring-boot-starter</artifactId>-->
      <!--<version>1.3.2</version>-->
    <!--</dependency>-->
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

8、編寫Hello Spring Boot的Controller

package com.example.bootopen.com;
 
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
public class HelloSpringBootController {
 
  @RequestMapping("/hello")
  public String hello() {
    return "Hello Spring Boot";
  }
}

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

9、修改配置文件 application.properties

注意:如果只是簡單測試項(xiàng)目只需要添加端口即可,其他數(shù)據(jù)源、緩存、靜態(tài)資源路徑也可以在此配置。

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

筆者推薦一種配置文件模式:另外新建2個(gè)配置文件,一個(gè)開發(fā)環(huán)境,一個(gè)線上環(huán)境,通過application.properties自由切換

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

10、啟動(dòng)項(xiàng)目 選擇Run、Debug啟動(dòng)

關(guān)于@SpringBootApplication注解說明:@SpringBootApplication開啟了Spring的組件掃描和springboot的自動(dòng)配置功能,相當(dāng)于將以下三個(gè)注解組合在了一起

(1)@Configuration:表名該類使用基于Java的配置,將此類作為配置類

(2)@ComponentScan:啟用注解掃描

(3)@EnableAutoConfiguration:開啟springboot的自動(dòng)配置功能

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

訪問項(xiàng)目 http://localhost:8089/hello

怎么在idea中創(chuàng)建Spring Boot項(xiàng)目

關(guān)于怎么在idea中創(chuàng)建Spring Boot項(xiàng)目就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站muchs.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

當(dāng)前標(biāo)題:怎么在idea中創(chuàng)建SpringBoot項(xiàng)目-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://muchs.cn/article48/dsgphp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、響應(yīng)式網(wǎng)站、面包屑導(dǎo)航、品牌網(wǎng)站建設(shè)外貿(mào)建站、電子商務(wù)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)