I'd like to know, using Spring XML profiles, if it is possible to declare Spring beans for all profiles, except the dev profile.
My usecase is that I would like to declare my JDBC datasource as being JNDI provided for profile "dev", while it is created for other profiles.
I'd like to have something like:
<beans profile="dev" >
... DataSource JNDI ...
</beans>
<beans profile="!dev" >
... DataSource creation ...
</beans>
Is there a solution? Or the only way is to do:
<beans profile="dev" >
... DataSource JNDI ...
</beans>
<beans profile="integration,valid,preprod,prod" >
... DataSource creation ...
</beans>
Thanks
You can use ! , for spring version higher than Spring 3.2 M1.
So this way is ok:
<beans profile="!dev" >
... DataSource creation ...
</beans>
A simpler way would be like this:
General datasource creation for any profile:
<bean name="datasource" ...>
then specific for dev:
<beans profile="dev" >
<bean name="datasource" ...>
</beans>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.