如何设置Maven在运行测试时覆盖另一个设置文件? [英] How to set up Maven to override a settings file for another when running a test?
问题描述
参见以下Maven生成的项目
See the following Maven generated project
target
classes
test-classes
src
main
java
scripts
resources
datasource-settings.xml
test
java
resources
datasource-settings.xml
我想,在运行测试时,使用test / resources / datasource-settings.xml中的设置而不是main / 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 ?
推荐答案
放在 $ {basedir}中的资源/ src / test / resources
(默认位置)将自动添加到Maven为您的单元测试设置的类路径中,并优先于放置在 $ {basedir中的资源} / SRC /主/资源
。所以你想要做的只是默认行为。
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.
这篇关于如何设置Maven在运行测试时覆盖另一个设置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!