将超类中的@Sql 与子类中的@Sql 合并 [英] Merging @Sql from superclass with @Sql in subclass

查看:42
本文介绍了将超类中的@Sql 与子类中的@Sql 合并的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用 @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someScript") 注释的抽象类.

I have an abstract class annotated with @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someScript") .

我有一个从抽象类继承的测试类.子类也用 @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someOtherScript") 注释.

I have a test class which inherits from the abstract class. The child class is also annotated with @Sql(executionPhase = ExecutionPhase.BEFORE_TEST_METHOD, scripts="someOtherScript").

当我运行 spring boot 1.2 时,一切都按我的预期工作:来自父类的脚本在子类之前运行.我升级到 spring boot 1.3 现在,子类的 @Sql 覆盖了父类的 @Sql 并且父类脚本永远不会运行.

When I was running spring boot 1.2, everything worked as I expected it to: scripts from parent class were run before child class. I upgraded to spring boot 1.3 and now, the child class's @Sql overrides parent class's @Sql and the parent class scripts are never run.

使用 spring boot 1.3 是否有不同的方式来做到这一点?所以父类脚本在子类脚本之前运行?

With spring boot 1.3 is there a different way of doing this? So that parent class scripts are run before child class scripts?

推荐答案

在@SamBrannen 的 answer 之后,我最终跑了使用 ScriptUtils.execute 方法的子类的脚本.

After @SamBrannen's answer, I ended up running the script from child class using ScriptUtils.execute method.

这篇关于将超类中的@Sql 与子类中的@Sql 合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆