Java 如何动态地自动连线服务
我有一个像BaseService这样的接口,还有两个类CoreServiceImpl和TenantServiceImpl,它们都扩展了BaseService。现在我想在我的控制器中自动连接BaseService,如何通过传递任何参数来运行特定的服务(核心/租户?您可以使用Java 如何动态地自动连线服务,java,spring-boot,Java,Spring Boot,我有一个像BaseService这样的接口,还有两个类CoreServiceImpl和TenantServiceImpl,它们都扩展了BaseService。现在我想在我的控制器中自动连接BaseService,如何通过传递任何参数来运行特定的服务(核心/租户?您可以使用@Profile: @Component @Profile("core") public class CoreServiceImpl {} @Component @Profile("tenant") public class
@Profile
:
@Component
@Profile("core")
public class CoreServiceImpl {}
@Component
@Profile("tenant")
public class TenantServiceImpl {}
然后使用
--spring.profiles.active=core/tenant运行spring
如果您能解释一下在哪一点上您想使用哪种OneHanks来获得所有支持,那会更好