1.在idea中創建maven專案


2.在pom.xml中添加依賴
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3.新建子工程


4.在子工程中創建controller

package com.sfencs.first;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class TestController {
@RequestMapping("hello")
public String hello() {
return "hello world";
}
}
5.創建springboot啟動類

package com.sfencs.first;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootApp {
public static void main(String[] args) {
SpringApplication.run(SpringBootApp.class,args);
}
}
6.運行啟動類main函式

瀏覽器輸入http://localhost:8080/hello

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/86714.html
標籤:Java
上一篇:Java 創建、重繪Excel透視表/設定透視表行折疊、展開
下一篇:微信掃碼登錄是如何實作的?
