title: How can I mock db connection in Spring Boot for testing purpose?
body: <p>Situation:</p>
  
  <ol>
  <li>I am using <code>Spring Cloud</code> with <code>Spring Boot</code> in a microservice, that microservice is loading a DB config information to configure a connection. </li>
  <li>I created a test to get the rest interfaces using <code>Swagger</code> for documentation.</li>
  <li>I want to disable the loading of DB configuration because is not necessary.</li>
  </ol>
  
  <p>Here is the code:</p>
  
  <pre><code>@WebAppConfiguration
  @RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = {Application.class, Swagger2MarkupTest.class}, loader = SpringApplicationContextLoader.class)
  @ActiveProfiles("test")
  
  public class Swagger2MarkupTest {
  
      @Autowired
      private WebApplicationContext context;
  
      private MockMvc mockMvc;
  
      @Autowired
      protected Environment env;
  
      @Before
      public void setUp() {
          this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context).build();
      }
  
      @Test
      public void convertSwaggerToAsciiDoc() throws Exception {
          this.mockMvc.perform(get("/v2/api-docs").accept(MediaType.APPLICATION_JSON))
                  .andDo(Swagger2MarkupResultHandler.outputDirectory("target/docs/asciidoc/generated")
                          .withExamples("target/docs/asciidoc/generated/exampless").build())
                  .andExpect(status().isOk());
      }
  }
  </code></pre>
  
  <p>How can I run the test without loading the database configuration?
  Is this possible?</p>