pom
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>1.5.2.RELEASE</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
SpringBootApplication
@SpringBootApplication
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}
RestController
@RestController
@RequestMapping("/demo")
public class DemoController {
@RequestMapping("/hello")
String home() {
return "Hello World!";
}
}
注意
SpringBootApplication默认扫描当前包下的RestController。自定义扫描目录时使用ComponentScan扫描指定的包。
github
https://github.com/darrenkeng/springboot