From a35185bbda1c0a737f724d02606dfab61eecd798 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Tue, 10 Feb 2015 23:25:55 +0800 Subject: [PATCH] Update 24. Profiles.md --- IV. Spring Boot features/24. Profiles.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/IV. Spring Boot features/24. Profiles.md b/IV. Spring Boot features/24. Profiles.md index e69de29..b7df576 100644 --- a/IV. Spring Boot features/24. Profiles.md +++ b/IV. Spring Boot features/24. Profiles.md @@ -0,0 +1,17 @@ +### 24. Profiles +Spring Profiles提供了一种隔离应用程序配置的方式,并让这些配置只能在特定的环境下生效。任何@Component或@Configuration都能被@Profile标记,从而限制加载它的时机。 +```java +@Configuration +@Profile("production") +public class ProductionConfiguration { + // ... +} +``` +以正常的Spring方式,你可以使用一个spring.profiles.active的Environment属性来指定哪个配置生效。你可以使用平常的任何方式来指定该属性,例如,可以将它包含到你的application.properties中: +```java +spring.profiles.active=dev,hsqldb +``` +或使用命令行开关: +```shell +--spring.profiles.active=dev,hsqldb +```