欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

使用IDEA創(chuàng)建SpringBoot項(xiàng)目的方法步驟

 更新時(shí)間:2018年05月14日 11:49:57   作者:S_H-A_N  
這篇文章主要介紹了使用IDEA創(chuàng)建SpringBoot項(xiàng)目的方法步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

1.打開(kāi)IDEA,創(chuàng)建新項(xiàng)目,選擇Spring Initializr


2.輸入Artifact


3.勾選Web


4.點(diǎn)擊finish完成

5.進(jìn)入項(xiàng)目,可以將以下內(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.example</groupId> 
 <artifactId>springbootdemo</artifactId> 
 <version>0.0.1-SNAPSHOT</version> 
 <packaging>jar</packaging> 
 
 <name>springbootdemo</name> 
 <description>Demo project for Spring Boot</description> 
 
 <!--起步依賴--> 
 <parent> 
  <groupId>org.springframework.boot</groupId> 
  <artifactId>spring-boot-starter-parent</artifactId> 
  <version>1.5.2.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> 
  <!--開(kāi)發(fā)web項(xiàng)目相關(guān)依賴--> 
  <dependency> 
   <groupId>org.springframework.boot</groupId> 
   <artifactId>spring-boot-starter-web</artifactId> 
  </dependency> 
  <!--springboot單元測(cè)試--> 
  <dependency> 
   <groupId>org.springframework.boot</groupId> 
   <artifactId>spring-boot-starter-test</artifactId> 
   <scope>test</scope> 
  </dependency> 
 </dependencies> 
 
 <!--maven構(gòu)建--> 
 <build> 
  <plugins> 
   <plugin> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-maven-plugin</artifactId> 
   </plugin> 
  </plugins> 
 </build> 
</project> 

6.創(chuàng)建一個(gè)HelloController

package com.example; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.RestController; 
@RestController 
public class HelloController { 
 @RequestMapping("/hello") 
 public String hello() { 
  return "hello,this is a springboot demo"; 
 } 
} 

7.程序自動(dòng)生成的SpringbootdemoApplication,會(huì)有一個(gè)@SpringBootApplication的注解,這個(gè)注解用來(lái)標(biāo)明這個(gè)類是程序的入口

package com.example; 
 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
 
//入口 
@SpringBootApplication 
public class SpringbootdemoApplication { 
 
 public static void main(String[] args) { 
  SpringApplication.run(SpringbootdemoApplication.class, args); 
 } 
} 

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

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

(2)@ComponentScan:?jiǎn)⒂米⒔鈷呙?/p>

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

8.運(yùn)行SpringbootdemoApplication類


測(cè)試:

在地址欄中輸入http://localhost:8080/hello


9.使用啟動(dòng)jar包的方式啟動(dòng)

(1)首先進(jìn)入項(xiàng)目所在目錄,如果是mac系統(tǒng)在項(xiàng)目上右鍵,選擇Reveal in Finder,Windows系統(tǒng)在項(xiàng)目上右鍵選擇Show in Explorer,即可打開(kāi)項(xiàng)目所在目錄

(2)打開(kāi)終端,進(jìn)入項(xiàng)目所在目錄

cd /Users/shanml/IdeaProjects/SpringbootDemo

輸入mvn install,構(gòu)建項(xiàng)目

(3)構(gòu)建成功后,在項(xiàng)目target文件夾下會(huì)多出一個(gè)jar包

(4)使用java -jar springbootdemo-0.0.1-SNAPSHOT.jar 

啟動(dòng)jar包即可

參考:

廖師兄:兩小時(shí)學(xué)會(huì)Springboot

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • maven學(xué)習(xí)-初窺門徑

    maven學(xué)習(xí)-初窺門徑

    這篇文章主要介紹了maven的簡(jiǎn)單知識(shí),介紹了maven的定義及核心功能,具有一定參考價(jià)值,大家可以了解下。
    2017-10-10
  • MyBatis生成UUID的實(shí)現(xiàn)

    MyBatis生成UUID的實(shí)現(xiàn)

    這篇文章主要介紹了MyBatis生成UUID的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12
  • 使用FileReader采用的默認(rèn)編碼

    使用FileReader采用的默認(rèn)編碼

    這篇文章主要介紹了使用FileReader采用的默認(rèn)編碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Spring MVC 擴(kuò)展和 SSM 框架整合步驟詳解

    Spring MVC 擴(kuò)展和 SSM 框架整合步驟詳解

    在前端頁(yè)面后后臺(tái)交互的過(guò)程中,需要一種格式清晰、高效且兩端都可以輕松使用的數(shù)據(jù)格式做交互的媒介,JSON正可以滿足這一需求,下面學(xué)習(xí)使用Spring MVC 框架處理JSON數(shù)據(jù),感興趣的朋友一起看看吧
    2024-08-08
  • Java class文件格式之訪問(wèn)標(biāo)志信息_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    Java class文件格式之訪問(wèn)標(biāo)志信息_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理

    access_flags 描述的是當(dāng)前類(或者接口)的訪問(wèn)修飾符, 如public, private等, 此外, 這里面還存在一個(gè)標(biāo)志位, 標(biāo)志當(dāng)前的額這個(gè)class描述的是類, 還是接口
    2017-06-06
  • 解析JavaSE的繼承和多態(tài)

    解析JavaSE的繼承和多態(tài)

    這篇文章主要為大家詳細(xì)介紹了JavaSE的繼承和多態(tài),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-03-03
  • Java數(shù)組,去掉重復(fù)值、增加、刪除數(shù)組元素的實(shí)現(xiàn)方法

    Java數(shù)組,去掉重復(fù)值、增加、刪除數(shù)組元素的實(shí)現(xiàn)方法

    下面小編就為大家?guī)?lái)一篇Java數(shù)組,去掉重復(fù)值、增加、刪除數(shù)組元素的實(shí)現(xiàn)方法。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-08-08
  • java實(shí)現(xiàn)文件變化監(jiān)控的方法(推薦)

    java實(shí)現(xiàn)文件變化監(jiān)控的方法(推薦)

    下面小編就為大家?guī)?lái)一篇java實(shí)現(xiàn)文件變化監(jiān)控的方法(推薦)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-08-08
  • SpringBoot之Refresh流程的簡(jiǎn)單說(shuō)明

    SpringBoot之Refresh流程的簡(jiǎn)單說(shuō)明

    這篇文章主要介紹了SpringBoot之Refresh流程的簡(jiǎn)單說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • Spingmvc中的HandlerMapping剖析

    Spingmvc中的HandlerMapping剖析

    這篇文章主要介紹了Spingmvc中的HandlerMapping剖析,Spingmvc中的HandlerMapping負(fù)責(zé)解析請(qǐng)求URL,對(duì)應(yīng)到Handler進(jìn)行處理,這里的Handler一般為Controller里的一個(gè)方法method,也可以為servlet或者Controller等,需要的朋友可以參考下
    2023-09-09

最新評(píng)論