本文通过Eclipse Maven 构建第一个SpringBoot小实例Demo。
1、创建maven项目
2、创建测试类
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@EnableAutoConfiguration
public class Test {
@RequestMapping("/")
String home(){
return "Hello springboot!";
}
public static void main(String args[]){
SpringApplication.run(Test.class,args);
}
}
3 启动Demo
运行Test.class类
4、查看效果
浏览器输入http://localhost:8080/