首页>代码>spring通过@Value注解注入到java List属性>/loading-list-from-properties-file-spring-@value/src/main/java/com/memorynotfound/spring/core/AppConfig.java
package com.memorynotfound.spring.core; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.PropertySource; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import java.util.List; @Configuration @PropertySource(value="classpath:application.properties") public class AppConfig { @Value("#{'${planets.names}'.split(',')}") private List<String> planets; @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } public List<String> getPlanets() { return planets; } }
最近浏览更多
全栈小白 LV34
2023年1月8日
364502984 LV18
2022年6月2日
shaoxf_nihao LV4
2022年5月31日
wsupsup LV16
2022年4月20日
dongyanbing LV4
2022年4月8日
tmdgdx LV9
2022年4月1日
and123456 LV11
2022年3月16日
szf123 LV12
2022年3月4日
xp95323 LV14
2022年1月25日
woaini12788 LV7
2022年1月13日