?使用IDEA快速創建springboot項目流程:
?
?創建新的項目選擇
?
?項目的命名以及包名
?
?
?需要什么包就導入什么包
?
?
?進行測試的單元
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope> </dependency>
?
此時的工程默認有這個啟動的主程序
Springboot01Application.java
@SpringBootApplication public class Springboot01Application {public static void main(String[] args) {SpringApplication.run(Springboot01Application.class, args);} }
?
?新建一個controller包和controller類:
//此時類的所有方法都會返回數據給瀏覽器(對象是專為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應用的配置文件