spring boot四:探究hello world
生活随笔
收集整理的這篇文章主要介紹了
spring boot四:探究hello world
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1. POM文件
? ?父項目:
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.9.RELEASE</version></parent>spring boot的版本仲裁中心,以后導入依賴默認不需要寫版本.(沒有在dependencies里面管理的依賴法則自然需要聲明版本號)
2. 導入的依賴項
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>spring-boot-starter: ?spring-boot 場景啟動器; 幫我們導入web模塊正常運行所依賴的組件。
spring-boot將所有的功能場景都抽取出來,做成一個個的starters(啟動器),只需要在項目里引入這些starter,相關場景的所有依賴都會導入進來。要用什么功能,就導入對應的場景的啟動器.
3. 主程序類,主入口類
@SpringBootApplication public class HelloWorldMainApplication {public static void main(String[] args) {// sping應用啟動起來SpringApplication.run(HelloWorldMainApplication.class, args);} } @SpringBootApplication: spring boot應用標注在某個類上說明這個類是springboot的主配置類,SpringBoot就應該運行這個類的main方法來啟動SpringBoot應用; @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @SpringBootConfiguration @EnableAutoConfiguration @ComponentScan(excludeFilters = {@Filter(type = FilterType.CUSTOM,classes = {TypeExcludeFilter.class} ), @Filter(type = FilterType.CUSTOM,classes = {AutoConfigurationExcludeFilter.class} )} ) public @interface SpringBootApplication {@SpringBootConfiguration:Spring Boot的配置類; 標注在某個類上,表示這是一個spring boot配置類.
@EnableAutoConfiguration:開啟自動配置功能。以前我們需要配置的東西,spring boot幫我們自動配置。?
?
?
?
?
總結
以上是生活随笔為你收集整理的spring boot四:探究hello world的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux:安装mysql
- 下一篇: spring一: 容器以及bean生命周