title: Spring Boot MongoRepository @Rollback for tests
body: <p>I wrote a Test for a MongoRepository in Spring Boot, and the test works fine. The only problem is that when the test is over, I want a rollback, so that there will be no change in the database caused by the test.</p>
  
  <pre><code>// package...
  
  // imports...
  
  @RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(classes = MetistrafficApplication.class)
  @Rollback(true)
  public class AppRepositoryTests {
  
      @Autowired
      private AppRepository appRepository;
  
      @Test
      public void insertTest() {
          App app = new App("test");
          App appInserted = appRepository.save(app);
  
          assertThat(appInserted.getName(), equalTo(app.getName()));
      }
  }
  </code></pre>
  
  <p>I put @Transactional before @Rollback, but get this error:</p>
  
  <pre><code>java.lang.illegalstateexception:Failed to retrieve PlatformTransactionManager for @Transactional test for test context
  </code></pre>
  
  <p>When I searched for the error, I couldn't find any code with MongoRepository. So, how can I solve this?</p>
  
  <p>EDIT: After adding <code>@Transactional("PlatformTransactionManager")</code>, the error I get is changed to this:</p>
  
  <pre><code>org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'PlatformTransactionManager' is defined: No matching PlatformTransactionManager bean found for qualifier 'PlatformTransactionManager' - neither qualifier match nor bean name match!
  </code></pre>