Spring-boot default profile for integration tests

后端 未结 11 1071
说谎
说谎 2020-12-07 14:49

Spring-boot utilizes Spring profiles (http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html) which allow for instance to have separate co

11条回答
  •  误落风尘
    2020-12-07 14:51

    In my case I have different application.properties depending on the environment, something like:

    application.properties (base file)
    application-dev.properties
    application-qa.properties
    application-prod.properties
    

    and application.properties contains a property spring.profiles.active to pick the proper file.

    For my integration tests, I created a new application-test.properties file inside test/resources and with the @TestPropertySource({ "/application-test.properties" }) annotation this is the file who is in charge of picking the application.properties I want depending on my needs for those tests

提交回复
热议问题