@ConfigurationProperties (prefix = "gever.modules.contract")
时间: 2024-01-29 07:00:00 浏览: 20
这是一个Spring Boot注解,用于将配置文件中以"gever.modules.contract"为前缀的属性注入到对应的Java类中。在这个例子中,被注入的Java类的名称应该是"ContractModuleProperties",并且它应该包含与配置文件中指定的属性相对应的属性(例如,如果在配置文件中有一个属性叫做"gever.modules.contract.enabled=true",那么在"ContractModuleProperties"类中应该有一个名为"enabled"的属性,并且它的值应该为true)。
相关问题
@ConfigurationProperties(prefix = "spring.datasource.
@ConfigurationProperties(prefix = "spring.datasource.")是一个注解,用于将配置文件中以"spring.datasource."开头的配置项注入给当前对象的属性。该注解可以加在方法上,也可以加在类上。当加在方法上时,会调用该方法返回的对象的属性的set方法,将配置文件的内容注入到对应的属性中。当加在类上时,会调用该类声明的属性的set方法,将配置文件的内容注入到对应的属性中。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [@Bean及@ConfigurationProperties(prefix = “spring.datasource“)](https://blog.csdn.net/qq_33524771/article/details/119211997)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [Java 常用注解@Configuration,@Bean及@ConfigurationProperties(prefix = "spring.datasource")](https://blog.csdn.net/qq_34207422/article/details/99640655)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
@ConfigurationProperties(prefix = "jdwx.sms")
`@ConfigurationProperties(prefix = "jdwx.sms")`是Spring Boot中的注解,用于将配置文件中以`jdwx.sms`为前缀的属性值注入到对应的Java Bean中。具体来说,它会将`application.properties`或`application.yml`中以`jdwx.sms`为前缀的属性值注入到一个Java Bean中,该Bean的属性名与配置文件中的属性名相同,属性值与配置文件中的属性值相同。这样做的好处是可以方便地管理和维护配置文件中的属性值,同时也可以避免硬编码。
例如,如果在`application.properties`中定义了以下属性:
```
jdwx.sms.username=your_username
jdwx.sms.password=your_password
jdwx.sms.url=http://your_url
```
那么可以定义一个Java Bean来接收这些属性值:
```java
@ConfigurationProperties(prefix = "jdwx.sms")
public class SmsProperties {
private String username;
private String password;
private String url;
// 省略getter和setter
}
```
这样,在其他Java类中就可以通过`@Autowired`注解将`SmsProperties`注入进来,然后使用其中的属性值。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.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)