Bird
0
0

Consider this configuration:

hard📝 Application Q9 of 15
Spring Boot - Spring Annotations
Consider this configuration:
@Profile("!prod")
@Component
public class NonProdService {}

What does the !prod profile expression mean?
AThe bean is active when the 'prod' profile is NOT active.
BThe bean is active only when 'prod' profile is active.
CThe bean is active regardless of profile.
DThe bean is active only if multiple profiles including 'prod' are active.
Step-by-Step Solution
Solution:
  1. Step 1: Understand negation in @Profile

    The exclamation mark '!' negates the profile, meaning the bean is active when that profile is NOT active.
  2. Step 2: Interpret '!prod'

    This means the bean is created in all profiles except 'prod'.
  3. Final Answer:

    The bean is active when the 'prod' profile is NOT active. -> Option A
  4. Quick Check:

    !profile means profile is inactive [OK]
Quick Trick: Use !profile to exclude a profile in @Profile [OK]
Common Mistakes:
  • Thinking !prod means active only in prod
  • Ignoring negation syntax
  • Assuming bean is always active

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes