1.public interface TestTemplate {
Response doSomeThing();
}
2.
`public abstract class SayHelloAb implements TestTemplate {
@Override
public Response doSomeThing() {
log.info("Hello");
doAnother();
return null;
}
protected abstract Response doAnother();
}`
- ctrl+o 重写父类方法
public class DoSayHello extends SayHelloAb{
@Override
public Response doSomeThing() {
return super.doSomeThing();
}
@Override
protected Response doAnother() {
log.info("another hello");
return null;
}
}
@Autowired
TestTemplate doSayHello;
@Test
public void testModel(){
doSayHello.doSomeThing();
}
[main] INFO c.b.t.s.s.s.testTemp.SayHelloAb:11 - Hello
[main] INFO c.b.t.s.s.s.testTemp.DoSayHello:19 - another hello