'How to exclude auto configurations in spring boot test?

I want to exclude some of the graphQL auto configurations. I tried by using @TestPropertySource, but it is not working.

The following code is my test class

@TestPropertySource(properties =
    {"spring.autoconfigure.exclude=org.springframework.graphql.boot.GraphQlAutoConfiguration,org.springframework.graphql.boot.GraphQlServiceAutoConfiguration,org.springframework.graphql.boot.GraphQlWebMvcAutoConfiguration"})
@SpringBootTest(classes = MyApp.class)
public class MyAppTest{
// test logic
}

My main application has following configurations

@SpringBootApplication(exclude = {GraphQlAutoConfiguration.class,
                GraphQlServiceAutoConfiguration.class,
                GraphQlWebMvcAutoConfiguration.class})
public class MyApp{
// main logic
}

Can anyone help me what mistake i was making.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source