:{}“, env.getProperty( “dm.filterPattern”)); logger.debug(“Handler Methods:{}”,handlerMethods.size());
for(RequestMappingInfo MAPINFO </跨度> :handlerMethods.keySet …()) { logger.debug(“Mappinginfo:{} - &gt; {}”, MAPINFO </跨度> ,handlerMethods.get( MAPINFO </跨度> )); } }}
具有bean定义的类
@组态@PropertySource(“classpath …
有可能 PropertySourcesPlaceholderConfigurer 在弹簧上下文中比控制器初始化,因此值不会被解析。尝试添加显式bean定义 PropertySourcesPlaceholderConfigurer 在其中一个根配置文件中,如下所示;
PropertySourcesPlaceholderConfigurer
@PropertySource("classpath:/dmConfig.properties") public class DmWebConfigurer extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { super.addResourceHandlers(registry); registry.addResourceHandler("/index.html").addResourceLocations("/"); registry.setOrder(Integer.MAX_VALUE-5); } @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); } }
你可以在你的正确看到值的原因 init() 方法是因为在初始化所有bean之后调用它包括 PropertySourcesPlaceholderConfigurer 。
init()