Including bean definition when a profile is NOT active

喜你入骨 提交于 2019-12-04 23:37:06
aweigold

You can use a not (!) operator... but you have to use Spring 3.2 M1.

The following syntax is now supported

<beans profile="A,!B">

@Profile("A", "!B")

indicating that the element or annotated component should be processed only if profile 'A' is active or profile 'B' is not active.

See change announced here: Spring Framework 3.2 M1 Released
The commit is at GitHub: Support not (!) operator for profile selection
Issue in JIRA: SPR-8728

If upgrading to Spring 3.2 is not possible for your project, I would recommend not using the @Profile approach and ensuring that the bean is not created in your Spring configuration.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!