Zzzxb's Blog

你要静心学习那份等待时机的成熟的情绪,也要你一定保有这份等待之外的努力和坚持。

Spring Boot 的启动方式

方式一(@SpringBootApplication)

@SpringBootApplication

package com.example.springbootstartingmode;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringBootStartingModeApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootStartingModeApplication.class, args);
    }

}

方式二(@EnableAutoConfiguration)

package com.example.springbootstartingmode;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

@EnableAutoConfiguration
@ComponentScan
public class SpringBootStartingModeApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootStartingModeApplication.class, args);
    }

}

Spring boot 加载 xml 配置文件

@ImportResource(locations = {"application.xml"})