利用SpringBoot框架搭建最简版的Web应用
废话不多说,上干货。
pom.xml 引入
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
启动类
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(MainApplication.class, args);
}
}
测试Action
@RestController
@RequestMapping("simple")
public class SimpleAction {
@RequestMapping("/index")
@ResponseBody
String index() {
return "Hello World!";
}
}
效果
搞定