> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](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).

# 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)的属性。
