Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
396 views
in Technique[技术] by (71.8m points)

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

See the following Maven generated project

target
    classes
    test-classes
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 ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...