springBoot入门
springBoot搭建以及测试
使用Maven搭建
1.创建Maven项目
2.勾选Create
3.选择jar 并添加父工程
4.创建完设置pom.xml文件
5.测试HelloWord
//编写Controller返回helloword
@Controller
public class HelloWorld {
@RequestMapping("/hello")
public String showHelloWorld(){
return "helloword";
}
}
//启动 SpringBoot 编写启动类
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
//访问测试 http://localhost:8080/hello
使用idea直接创建springBoot项目
如之前使用Eclipse一样
测试:在自动创建的application上运行
public class Springboot01Application {
public static void main(String[] args) {
SpringApplication.run(Springboot01Application.class, args);
}
}
完成