springboot 创建一个HelloWorld应用并且运行

1.创建一个helloworld主程序类

/**
* @SpringBootApplication 用来标注一个主程序类,这是一个SpringBoot应用
*/
@SpringBootApplication
public class SpringBootHellowordConfigApplication {

public static void main(String[] args) {

//Spring应用启动
SpringApplication.run(SpringBootHellowordConfigApplication.class,args);
}

}

2.写一个controller

@Controller
public class HelloController {

@ResponseBody
@RequestMapping("/hello")
public String helloController(){
return "hello controller";
}

}
3.运行主配置类,后查看端口号
  

4.浏览器运行:http://localhost:8081/hello 即可

posted @ 2019-08-20 16:47  测试一枚  阅读(799)  评论(0编辑  收藏  举报