spring_reference/IV. Spring Boot features/22.2. Customizing SpringApp...

14 lines
928 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 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 配置](23. Externalized Configuration.md)。查看配置选项的完整列表,可参考[SpringApplication Javadoc](http://docs.spring.io/spring-boot/docs/1.2.2.BUILD-SNAPSHOT/api/org/springframework/boot/SpringApplication.html).