MySql教程

junit查询mysql数据库的数据_Junit BeforeClass 怎么获取数据库连接?

本文主要是介绍junit查询mysql数据库的数据_Junit BeforeClass 怎么获取数据库连接?,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

想在BeforeClass里面获取数据库连接,在跑测试之前把当前数据库中的数据线备份掉。

不太想要在里面写死,想调用root-context.xml里面配置的数据库连接

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations = {"classpath:spring/root-context.xml"})

public class Demo extends JunitBase {

@Autowired

private DemoService testClass;

@BeforeClass

public static void beforeAll() throws Exception {

// 在这里怎么获取root-context.xml里面配置的数据库连接

}

root-context.xml

destroy-method="close">

想在BeforeClass里面获取数据库连接,在跑测试之前把当前数据库中的数据线备份掉。 不太想要在里面写死,想调用root-context.xml里面配置的数据库连接 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:spring/root-context.xml"}) public class Demo extends JunitBase { @Autowired private DemoService testClass; @BeforeClass public static void beforeAll() throws Exception { // 在这里怎么获取root-context.xml里面配置的数据库连接 } root-context.xml destroy-method="close">
这篇关于junit查询mysql数据库的数据_Junit BeforeClass 怎么获取数据库连接?的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!