【发布时间】:2021-07-26 06:07:57
【问题描述】:
下面是我的界面:-
interface Student {
findById();
}
以下是我的 2 个接口实现:-
class Matriculation implements Student {
findById(){
//implementation
}
}
class Graduation implements Student {
findById(){
//implementation
}
}
application.properties
毕业=真
调用类:-
class Test {
@Autowired
Student student ;
method(){
student.findById();
}
}
如果毕业是真的,我想调用毕业班 findById 否则我想调用预科 findById 方法。我如何在 SpringBoot 中实现这一点?
【问题讨论】:
-
只需使用 if else 条件检查值,使用 @Value 进行毕业(字符串/布尔值)。
标签: spring spring-boot spring-mvc spring-data-jpa spring-data