IDEA springboot use to quickly create project process:
Create a new project selection
The project name and package name
What we need to import what package package
Unit testing
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency>
At this point the project by default have the start of the main program
Springboot01Application.java
@SpringBootApplication public class Springboot01Application { public static void main(String[] args) { SpringApplication.run(Springboot01Application.class, args); } }
Create a packet controller and controller classes:
//此时类的所有方法都会返回数据给浏览器(对象是专为json) //@RestController = @ResponseBody + @Controller @ResponseBody @Controller public class Helloword { @RequestMapping("/hello") public String hello(){ return "Hello tow!"; } }
运行访问:
springboot工程结构:
static文件夹:保存所有的静态资源
templates文件夹:保存所有的模板页面(Springboot默认jar使用嵌入式的Tomcat,默认不支持jsp页面);可以使用模板引擎
application.properties:springboot应用的配置文件