Which one of the following annotation is used to load application. properties file in the REST web application? A.@PropertiesResource B.@PropertiesSource C.@PropertySource D.@propertyResource
时间: 2024-03-21 12:41:09 浏览: 19
The correct annotation to load application.properties file in a REST web application is C. `@PropertySource`.
`@PropertySource` is a Spring Framework annotation that is used to declare a `PropertySource` to be used by the `Environment`. This annotation can be used at the class level or the method level. When used at the class level, it can be used to load properties from a properties file, a YAML file, or a Java properties object.
For example, to load the `application.properties` file in a Spring Boot application, you can use the `@PropertySource` annotation as follows:
```
@Configuration
@PropertySource("classpath:application.properties")
public class AppConfig {
// ...
}
```
This will load the `application.properties` file from the classpath and make it available to the `Environment` for use in the application.
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)