Load environment-specific properties for use with PropertyPlaceholderConfigurer?

后端 未结 8 1172
夕颜
夕颜 2020-12-23 17:24

This seems like a pretty common problem, but I haven\'t found any sort of consensus on the best method, so I\'m posing the question here.

I\'m working on a command-l

8条回答
  •  無奈伤痛
    2020-12-23 17:30

    You could use in your Spring XML and configure ${target_env} using a command-line argument (-Dtarget_env=test.).

    Starting in Spring 3.1 you could use and specify a default value, thereby eliminating the need to set the value on the command-line.

    In case Maven IS an option, the Spring variable could be set during plugin execution, e.g. during test or integration test execution.

    
        org.apache.maven.plugins
        maven-surefire-plugin
        2.12
        
            
                test.
            
        
    
    

    I assume different Maven profiles would also work.

提交回复
热议问题