Spring 使用 @Value 注解读取配置 properties

mac2024-04-05  57

1. spring-mvc.xml 文件下加载配置文件(location 中是配置文件的位置)

<!-- 加载配置属性文件 --> <context:property-placeholder ignore-unresolvable="true" location="classpath:config.properties" />

2. 类中使用注解(读取对应的属性)

@Value("${http_base_url}") private String http_base_url;

 

最新回复(0)