From 081115d5631339c2855093393b332ad0907e1d80 Mon Sep 17 00:00:00 2001 From: qibaoguang Date: Tue, 10 Feb 2015 23:11:09 +0800 Subject: [PATCH] Update 23.7.1. Third-party configuration.md --- .../23.7.1. Third-party configuration.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/IV. Spring Boot features/23.7.1. Third-party configuration.md b/IV. Spring Boot features/23.7.1. Third-party configuration.md index e69de29..064e9f3 100644 --- a/IV. Spring Boot features/23.7.1. Third-party configuration.md +++ b/IV. Spring Boot features/23.7.1. Third-party configuration.md @@ -0,0 +1,13 @@ +### 23.7.1. 第三方配置 + +正如使用@ConfigurationProperties注解一个类,你也可以在@Bean方法上使用它。当你需要绑定属性到不受你控制的第三方组件时,这种方式非常有用。 + +为了从Environment属性配置一个bean,将@ConfigurationProperties添加到它的bean注册过程: +```java +@ConfigurationProperties(prefix = "foo") +@Bean +public FooComponent fooComponent() { + ... +} +``` +和上面ConnectionSettings的示例方式相同,任何以foo为前缀的属性定义都会被映射到FooComponent上。