gpt4 book ai didi

java - Spring Boot 和 Teradata UnsatisfiedDependencyException

转载 作者:行者123 更新时间:2023-12-01 09:14:40 26 4
gpt4 key购买 nike

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

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

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 无法注入(inject)具有该名称的类。要解决这个问题,只需在您的上下文中定义一个 DataSource - 此时 Spring 将能够注入(inject) bean 并正确引导上下文。

关于java - Spring Boot 和 Teradata UnsatisfiedDependencyException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40653520/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com