Spring 引导和 Teradata UnsatisfiedDependencyException

Spring Boot and Teradata UnsatisfiedDependencyException

我正在尝试使用 Teradata 数据库创建一个简单的 Spring 应用程序。

它正在使用 mySql 数据库和驱动程序,但在更改为 Teradata driver/databased 后,我收到以下异常:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.IllegalArgumentException: URL must start with 'jdbc'

应用程序属性:

spring.datasource.url =jdbc:teradata://servername/db
spring.datasource.username = dbc
spring.datasource.password = dbc
spring.datasource.driverClassName=com.ncr.teradata.TeraDriver

我认为这是 Spring 的问题,您可能在构造函数上使用 @Autowire,但 spring 无法使用该名称注入 class。要解决这个问题,只需在您的上下文中定义一个 DataSource - 此时 Spring 将能够注入 bean 并正确 bootstrap 上下文。