1、创建板子
public interface TestTemplate {
String test();
}
2、实现板子
@Service
public class TestTemplateImpl implements TestTemplate {
String test() {
return "success";
}
}
3、替换板子
例如不在同一个包下 命名确实一样的可以使用注解@Primary 来替换或者修改自动装配的实现类等等各种替换吧
如果全限定名字不一样的话就不需要进行注解@Primary 例如xxxxTestTemplateImpl只要去掉结尾大写开头的Impl命名不一致就行
@Service
@Primary
public class TestTemplateImpl implements TestTemplate {
String test() {
return "success";
}
}