我是使用 apache-cxf 的 spring boot2 新手。我正在尝试加载 yml 属性,但它返回的是空对象。
当我使用 spring.config.location=classpath:application.yml 时,它正在正确加载。如果我什么都不提供,那么它就不会加载 application.yml。
我把 applicatin.yml 是 src\main\resources 这是我的示例代码:
@SpringBootApplication
@ComponentScan(basePackages = {"com.ironmountain"})
@ConfigurationPropertiesScan(basePackages = {"com.ironmountain"})
@EnableCaching
public class Boot2Main extends SpringBootServletInitializer {
private static final IrmLogger IRMLOGGER = IrmLoggerFactory.getIrmLogger(Boot2Main.class);
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Boot2Main.class);
}
public static void main(String[] args) {
IRMLOGGER.debug("Starting Customer Facing web app");
SpringApplication.run(Boot2Main.class, args);
}
}
Jaxrs configuration:
@Bean
public JAXRSServerFactoryBean getJAXRSServerFactoryBean() {
JAXRSServerFactoryBean factoryBean = new JAXRSServerFactoryBean();
factoryBean.setBus(bus);
factoryBean.setProviders(getProviders());
factoryBean.setServiceBeans(getJaxrsResources());
factoryBean.setInInterceptors(getInInterceptors());
factoryBean.setFeatures(getFeatures());
factoryBean.setOutInterceptors(getOutInterceptors());
factoryBean.setOutFaultInterceptors(getOutInterceptors());
factoryBean.setAddress("/");
irmLogger.debug("JAX-RS Server Factory Beans added");
return factoryBean;
}
apache-cxf version =3.3.7
Spring boot version = 2.3.1
external tomcat = 9.0.36
Appreciate your help