# 24.7.5. @ConfigurationProperties vs @Value

`@Value`标注是Spring容器的一个核心特性，它没有提供跟类型安全的配置属性相同的特性。下面的表格总结了`@ConfigurationProperties`和`@Value`支持的特性：

| 特性                                                                                                                                    | `@ConfigurationProperties` | `@Value` |
| ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------- | -------- |
| [Relaxed绑定](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-relaxed-binding) | Yes                        | No       |
| [Meta-data支持](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata)                      | Yes                        | No       |
| `SpEL`表达式                                                                                                                             | No                         | Yes      |

如果你为自己的组件定义了一系列的配置keys，我们建议你将它们以`@ConfigurationProperties`注解的POJO进行分组。由于`@Value`不支持relaxed绑定，所以如果你使用环境变量提供属性值的话，它就不是很好的选择。最后，尽管`@Value`可以写`SpEL`表达式，但这些表达式不会处理来自[Application属性文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-application-property-files)的属性。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/24.-externalized-configuration/24.7.-type-safe-configuration-properties/24.7.5.-configurationproperties-vs.-value.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
