1 新建maven工程; 设置 maven配置*3 和 自动启动*1。
2 pom.xml添加依赖
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.0.1.RELEASE</version> </dependency> </dependencies>
3 添加com包,添加启动类,controller类
@SpringBootApplication public class MySpringboot { public static void main(String[] args){ SpringApplication.run(MySpringboot.class, args); } }
@Controller public class MyController { @RequestMapping("/hello") @ResponseBody public String hello(){ return "hello world"; } }
4 MySpringboot启动类,点击启动按钮;浏览器访问;
localhost:8080/hello