springboot中HelloWorldApplication的探究是怎樣的

springboot中Hello World Application的探究是怎樣的,相信很多沒有經(jīng)驗(yàn)的人對(duì)此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個(gè)問題。

成都創(chuàng)新互聯(lián)公司主要從事網(wǎng)站制作、網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)尼金平,10余年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-86922220

1. POM文件

1. 父項(xiàng)目

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>
    
    spring-boot-starter-parent的父項(xiàng)目:
    <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-dependencies</artifactId>
		<version>1.5.9.RELEASE</version>
		<relativePath>../../spring-boot-dependencies</relativePath>
	</parent>
	
	spring-boot-dependencies真正來管理Spring Boot項(xiàng)目中所有的依賴版本

Spring Boot的版本仲裁中心,以后我們導(dǎo)入依賴默認(rèn)不需要寫版本(沒有在spring-boot-dependencies中的依賴就需要聲明版本號(hào))

2. 導(dǎo)入的依賴

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

spring-boot-starter-web :

  • spring-boot-starter: spring boot場(chǎng)景啟動(dòng)器

2. 主程序類,主入口類

/**
 * @SpringBootApplication 來標(biāo)注一個(gè)主程序類,說明這是一個(gè)Spring boot應(yīng)用
 */
@SpringBootApplication
public class HelloWorldMainApplication {

    public static void main(String[] args) {

        //啟動(dòng)Spring應(yīng)用
        SpringApplication.run(HelloWorldMainApplication.class, args);
    }
}

@SpringBootApplication: Spring Boot應(yīng)用注解,標(biāo)注在某個(gè)類上說明這是Spring Boot應(yīng)用的主入口類,SpringBoot就應(yīng)該運(yùn)行這個(gè)類的main方法來啟動(dòng)應(yīng)用SpringBoot應(yīng)用

@SpringBootAppliation

@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 {
    @AliasFor(
        annotation = EnableAutoConfiguration.class,
        attribute = "exclude"
    )
    Class<?>[] exclude() default {};

    @AliasFor(
        annotation = EnableAutoConfiguration.class,
        attribute = "excludeName"
    )
    String[] excludeName() default {};

    @AliasFor(
        annotation = ComponentScan.class,
        attribute = "basePackages"
    )
    String[] scanBasePackages() default {};

    @AliasFor(
        annotation = ComponentScan.class,
        attribute = "basePackageClasses"
    )
    Class<?>[] scanBasePackageClasses() default {};
}

@SpringBootConfiguration

  • SpringBoot的配置類,標(biāo)準(zhǔn)在某個(gè)類上,表示這是一個(gè)SpringBoot的配置類

  • @Configuration:配置類(配置文件) -- 也是一個(gè)組件Component

@EnableAutoConfiguration

  • 開啟自動(dòng)配置功能

看完上述內(nèi)容,你們掌握springboot中Hello World Application的探究是怎樣的的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!

網(wǎng)站題目:springboot中HelloWorldApplication的探究是怎樣的
文章位置:http://muchs.cn/article12/ipihgc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗(yàn)、網(wǎng)頁設(shè)計(jì)公司、App設(shè)計(jì)、企業(yè)建站全網(wǎng)營(yíng)銷推廣、網(wǎng)站收錄

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化