springboot搭建
1、idea新建maven项目
2、pom.xml引入下面代码
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
3、新建application.java
@SpringBootApplication
public class WebApplication {
public static void main(String[] args) { SpringApplication.run(WebApplication.class, args); }
}
4、新建controller
@Controller
public class IndexController {
@RequestMapping("/index")
@ResponseBody
public String index() {
return "Hello World!";
}
}
5、启动main方法,浏览器打开/index,出现helloword