发布于2022年11月4日3年前 想在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">
创建帐户或登录后发表意见