时间:1小时左右
代码:200行左右
博客:1
知识点:springboot入门操作
package com.atguigu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @SpringBootApplication 来标注一个主程序类,说明这是一个Spring Boot应用
*/
@SpringBootApplication
public class HelloWorldMainApplication {
public static void main(String[] args) {
// Spring应用启动起来
SpringApplication.run(HelloWorldMainApplication.class,args);
}
}
package com.atguigu.springboot.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; //这个类的所有方法返回的数据直接写给浏览器,(如果是对象转为json数据) /*@ResponseBody @Controller*/ @RestController public class HelloController { @RequestMapping("/hello") public String hello(){ return "hello world quick!"; } // RESTAPI的方式 }