springboot junit 不能保存到数据库

来源:互联网 发布:云计算架构师培训 编辑:程序博客网 时间:2024/05/28 23:10

添加注解

@Rollback(false)

完整代码如下:

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