I have a Java web app with spring boot
When run test I need to exclude some Java config files:
Test config (need to include when test run):
@
You can also use @ConditionalOnProperty
like below:
@ConditionalOnProperty(value="otpConfig", havingValue="production")
@Configuration
@PropertySource("classpath:otp.properties")
public class OTPConfig { }
and for test:
@ConditionalOnProperty(value="otpConfig", havingValue="test")
@Configuration
@PropertySource("classpath:otp-test.properties")
public class TestOTPConfig { }
Than specify in your main/resources/config/application.yml
otpConfig: production
and in your test/resources/config/application.yml
otpConfig: test