開始學(xué)習(xí)Spring Boot
新建一個(gè)Maven 項(xiàng)目
參考IntelliJ IDEA CE 創(chuàng)建Maven項(xiàng)目
- 在
pom.xml
增加
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
</parent>
<dependencies>
<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>
- 創(chuàng)建一個(gè)
Application.java
package com.denghb.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* hello spring boot
*
* @author denghb
*/
@RestController
@EnableAutoConfiguration
public class Application {
@RequestMapping("/")
public String home() {
return "Hello World!";
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
- 項(xiàng)目結(jié)構(gòu)
- 右鍵運(yùn)行
Application.java
瀏覽器打開
http://localhost:8080/