spring property substitution for test and production

前端 未结 5 1147
余生分开走
余生分开走 2020-11-30 19:40

I ran into this for property substitution in spring


but u

5条回答
  •  眼角桃花
    2020-11-30 20:15

    Put the property-placeholder configuration in an extra spring xml configuration file.

    For example:

    • applicationContext.xml -- for the normal configration without any property-placeholder configuration
    • applicationContext-config.xml -- contains only a property-placeholder that load the production config file.
    • testApplicationContext.xml. This file includes the applicationContext.xml and uses a property-placeholder with an other properties file.

    In a Web App you could load all production spring context files with this pattern applicationContext*.xml.

    For the tests you need only to load testApplicationContext.xml this will include the normal config, but with other properties.

提交回复
热议问题