In the @Profile annotation documentation there is a statement:
If a given profile is prefixed with the NOT operator (!), the annotated component will be registered if the profile is not active — for example, given @Profile({"p1", "!p2"}), registration will occur if profile 'p1' is active or if profile 'p2' is not active.
And in the following example MyRepoImpl
will be created as a Spring bean when the uat
profile is active:
@Repository
@Profile({"dev", "!prod"})
public class MyRepoImpl implements MyRepo {...}
In this case what is the reason for specifying profiles other than !prod
(dev
in this example)?
As once prod
is not active that beans will be created. Is not it kind of excessive unnecessary configuration?