开发者

How to set up Maven to override a settings file for another when running a test?

开发者 https://www.devze.com 2022-12-20 23:39 出处:网络
See the following Maven generated project target classes test-c开发者_如何学运维lasses src main java

See the following Maven generated project

target
    classes
    test-c开发者_如何学运维lasses
src
    main
        java
        scripts
        resources
            datasource-settings.xml
    test
        java
        resources
            datasource-settings.xml

I would like, when running a test, to use the settings found in test/resources/datasource-settings.xml instead of main/resources/datasource-settings.xml. Is it possible ? If so, what should i do to get my goal ?


Resources placed in ${basedir}/src/test/resources (the default location) will be automatically added to the class path set up by Maven for your unit tests and take precedence over resources placed in ${basedir}/src/main/resources. So what you want to do is actually just the default behavior.


If you haven't modified the resource settings in your POM, the test resources should show up in your classpath first, so a test should find that file before the main one without you needing to do anything extra. What sort of behavior are you seeing?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号