springboot junit 不能保存到数据库

添加注解

@Rollback(false)

完整代码如下:

@RunWith(SpringRunner.class)
@SpringBootTest(classes=Application.class,webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext
@EnableTransactionManagement
public class ESBLogInRepositoryTest {
	
	@Autowired
	@Qualifier("esbLogInDao")
	private ESBLogInRepository esbLogInRepo;
	
	@Test
	@Transactional
	@Rollback(false)
	public void createInTableTest(){
		esbLogInRepo.createInTable("ESB_2017");
	}

}


你可能感兴趣的:(springboot,junit,springboot,junit)