• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

Quick basic Spring question about @ConditionalOnProperty and @ImportResource

Ranch Hand
Posts: 563
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very basic and quick question about the use of @ConditionalOnProperty and @ImportResource annotations.

If the condition is not met (that is the module.enable property is set to false in a properties file) then the ConfigA bean will not be loaded but the resources (myconf.xml) will still be imported. Am i right ?

Whether the condition is true or false, the resources will always be loaded. Correct ? Thanks for helping.
Ranch Hand
Posts: 1795
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By definition, @ConditionOnProperty means when a property is specified, create the bean. Or, when a property is missing, create the bean.
It depends on the matchIfMissing is true or false.

And @ImportResource is used to import the config file in xml.
These two annotations can co-exists without conflict.

You may want to post your code on GitHub and let us run it.

Friends help you move. Good friends help you move bodies. This tiny ad will help:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!