diff --git a/IV. Spring Boot features/22.2. Customizing SpringApplication.md b/IV. Spring Boot features/22.2. Customizing SpringApplication.md index e69de29..23f2ee1 100644 --- a/IV. Spring Boot features/22.2. Customizing SpringApplication.md +++ b/IV. Spring Boot features/22.2. Customizing SpringApplication.md @@ -0,0 +1,13 @@ +### 22.2. 自定义SpringApplication + +如果默认的SpringApplication不符合你的口味,你可以创建一个本地的实例并自定义它。例如,关闭banner你可以这样写: +```java +public static void main(String[] args){ + SpringApplication app = new SpringApplication(MySpringConfiguration.class); + app.setShowBanner(false); + app.run(args); +} +``` +**注**:传递给SpringApplication的构造器参数是spring beans的配置源。在大多数情况下,这些将是@Configuration类的引用,但它们也可能是XML配置或要扫描包的引用。 + +你也可以使用application.properties文件来配置SpringApplication。具体参考[Externalized 配置](#Externalized 配置)。查看配置选项的完整列表,可参考[SpringApplication Javadoc](http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/api/org/springframework/boot/SpringApplication.html).