lundi 11 novembre 2019

Is there a way to not start the spring boot application depending on the active profile?

I would like to know if there was a way to not start the spring boot application depending on the active profile. The reason for this is, I have two profiles: local, and integration. When the profile is local, then I would start the application locally. If the profile is integration, I would like the test to not start the application, but rather just use the endpoints I've set in the configuration class so that it would actually use the deployed spring boot application.

@SpringBootTest(
        webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT
)
@ContextHierarchy({
        @ContextConfiguration(
                initializers = ConfigFileApplicationContextInitializer.class,
                classes = TestConfiguration.class,
                loader = SpringBootContextLoader.class
        ),
        @ContextConfiguration(
                initializers = ConfigFileApplicationContextInitializer.class,
                classes = Application.class,
                loader = SpringBootContextLoader.class
        ),
    }
)
public class SpringContextConfiguration {

    @Before
    public void init(){}

}

Aucun commentaire:

Enregistrer un commentaire