In my code @Profile({ "!a" })
excludes a bean from usage in profile a
.
However if I specify @Profile({ "!a", "!b" })
it still gets used in profile b
.
Is there any way to exclude a bean from two profiles at the same time without specifying a whitelist for profiles?
Asked
Active
Viewed 620 times
1

mle
- 2,466
- 1
- 19
- 25
-
1Possible duplicate of [How to conditionally declare Bean when multiple profiles are not active?](https://stackoverflow.com/questions/35429168/how-to-conditionally-declare-bean-when-multiple-profiles-are-not-active) – Doron Gold Nov 28 '18 at 14:28
1 Answers
1
You can use logical operators and form an expression.
Example: @Profile("!a & !b")

Ranjan
- 390
- 2
- 10