如何定义用于 apache camel 的 MS SQL 数据源?

How to define an MS SQL datasource for use in apache camel?

我正在尝试创建一个用于 Apache camel sql 组件的数据源,并且根据 documentation 我已经定义了 spring 数据源属性和 在我的 pom 文件中包含依赖项:

        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-jdbc-starter</artifactId>
        </dependency>

        <!-- Component dependencies-->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-sql-starter</artifactId>
        </dependency>

        <!-- MS SQL jdbc driver -->
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
            <version>8.2.2.jre11</version>
        </dependency>

我什至根据许多阅读示例定义了一个配置的数据源(如果我没记错的话,如果定义了 spring 默认数据源属性,则不需要):

@Configuration
public class DataSourceConfig {

    @Bean(name = "etlDataSource")
    @ConfigurationProperties("spring.datasource")
    public DataSource getDataSource(){
        return DataSourceBuilder.create().build();
    }
}

到目前为止,我的努力都导致了同样的错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'etlDataSource' defined in class path resource [com/test/camel/etl/config/DataSourceConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'getDataSource' threw exception; nested exception is java.lang.IllegalStateException: No supported DataSource type found

对于我所缺少的内容,我将不胜感激。

编辑:

我定义的数据源属性:

spring:
  datasource:
    password: some_passw0rd
    url: jdbc:sqlserver://localhost:1433;trustServerCertificate=false;loginTimeout=30;
    username: sa
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    platform: mssql

我解决了。我查看了 DataSourceBuilder source 并看到构建方法试图确定类型,所以我在实例化中指定了一个并且它起作用了:

    @Bean(name = "etlDataSource")
    @ConfigurationProperties("spring.datasource")
    public DataSource getDataSource(){
        return DataSourceBuilder.create().type(BasicDataSource.class).build();
    }