配置:
import com.objectsql.ObjectSQLManager; import com.objectsql.SQLService; import com.objectsql.SQLServiceImpl; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; import javax.sql.DataSource; @Configuration public class ManagerConfiguration { @Bean @ConditionalOnBean(ObjectSQLManager.class) public ObjectSQLManager dataSourceManager(DataSource dataSource) { return new ObjectSQLManager(dataSource); } @Bean @ConditionalOnBean(DataSourceManager.class) public SQLService sqlService(){ return new SQLServiceImpl(); } } |
用法同 Spring 使用配置章节。