1.建立maven工程
2.打开pom文件, 将以下配置拷贝过去
1 <parent> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-parent</artifactId> 4 <version>1.5.8.RELEASE</version> 5 </parent> 6 <dependencies> 7 <dependency> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId>spring-boot-starter-web</artifactId> 10 </dependency> 11 <dependency> 12 <groupId>org.springframework.boot</groupId> 13 <artifactId>spring-boot-starter</artifactId> 14 </dependency> 15 </dependencies>
3.java文件内启动springboot, 并编写一个测试方法来测试
/** * Hello world! * */ @SpringBootApplication public class App { public static void main( String[] args ) { SpringApplication.run(App.class, args); } @Controller public class TestController { @RequestMapping("/hello") @ResponseBody public String hello() { return "hello"; } } }
4.打开java文件,右键==> Run As==> Java Application, 等待启动完成, 浏览器测试显示如下