简体   繁体   English

忽略propertyplaceholder-Spring Boot

[英]Ignore propertyplaceholder - Spring Boot

I am using the below statement to component scan all the beans defined in my applications dependent jar file - 我正在使用以下语句对我的应用程序依赖的jar文件中定义的所有bean进行组件扫描-

@ImportResource({"classpath*:/META-INF/spring.xml"})

I have a bean defined in one of the spring.xml which is looking for a property placeholder file:${service.propDir} . 我在spring.xml之一中定义了一个Bean,它正在寻找属性占位符文件:$ {service.propDir} The bean is no longer required but I can't remove it as it is part one of the jar file. 不再需要该bean,但是我不能删除它,因为它是jar文件的一部分。 Is there a way to ignore property placeholders , if not available in this scenario? 如果在这种情况下不可用,有没有办法忽略属性占位符?

Cleanly will be to remove it completely. 干净地将其完全删除。 However if you're still holding to it using a default value should work for you: ${service.propDir:defaultValue} Another option would be Using @Conditional or @Profile here is a good blog about these two 但是,如果您仍然坚持使用default值,则应该适合您: ${service.propDir:defaultValue}另一个选择是使用@Conditional@Profile 这里是有关这两个的不错的博客

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM