当前位置: 首页 > 知识库问答 >
问题:

Spring Boot应用程序-Tomcat部署-无法确定合适的驱动程序类

郗亦
2023-03-14

从IDE运行时,一切看起来都很好

尝试在tomcat服务器中部署应用程序时,出现以下错误。

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': 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$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class

应用JAVA

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(Application.class);
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }
}

build.gradle

plugins {
    id 'java'
}

sourceCompatibility = 1.8

apply plugin: 'java'
apply plugin: 'war'

repositories {
    mavenCentral()
    maven { url "http://dayrhebfmi001.enterprisenet.org:8081/artifactory/libs-snapshot"}
}

dependencies {
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.1.7.RELEASE'
    compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.1.7.RELEASE'
    compile group: 'org.postgresql', name: 'postgresql', version: '42.2.6'
    compile group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
    annotationProcessor group: 'org.projectlombok', name: 'lombok', version: '1.18.8'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.28'
    testCompile group: 'junit', name: 'junit', version: '4.12'
    providedRuntime group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat', version: '2.1.8.RELEASE'

}

application.properties

spring.datasource.platform=xxxxx
spring.datasource.url=xxxxx
spring.datasource.username=xxxxx
spring.datasource.password=xxxxx
spring.jpa.show-sql=true
spring.datasource.driver-class-name=org.postgresql.Driver

共有2个答案

何安宜
2023-03-14

您应该将驱动程序类配置添加到应用程序中。属性:

spring.datasource.driver-class-name=org.postgresql.Driver
楮法
2023-03-14

无法实例化[com.zaxxer.hikari.HikariDataSource]:工厂方法'dataSource'抛出异常;嵌套异常org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreation异常:无法确定合适的驱动程序类

你的房产有几处看起来可疑。但是我认为你可以通过按要求给它起类名来解决这个特定的错误。

spring。数据源。驱动程序类名=oracle。jdbc。OracleDriver

(或您正在使用的任何数据库)

增加额外点数

spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect

(再说一遍,或者你正在使用的任何数据库

编辑:当然,除非您已经将数据库驱动程序jar文件放在tomcat/lib中,否则您需要将其添加到依赖项中,以便将其绑定到war文件中。

 类似资料:
  • 启动应用程序时,出现以下错误: 上下文初始化过程中遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException:创建名为“Block DataController”的bean时出错:注入资源依赖项失败;嵌套异常为org.springframework.beans.factory.beanCreationException:创

  • 完成干净的构建后,我将war文件复制到Tomcat的文件夹中。但是部署会发生两次,并且在上下文已经存在的情况下以异常结束。我错过了什么? 非常感谢您的帮助。

  • 我正在尝试使用SpringBoot和Postgres数据库开发web应用程序。然而,在连接到应用程序时,我遇到了错误“无法确定合适的驱动程序类”,正如以前帖子中的建议,我尝试使用不同版本的jdbc驱动程序,还尝试手动为NamedParameterJdbcTemplate创建bean。我还验证了库是否存在,是否可以从Java代码访问,以及类路径中是否存在这些库。但它仍然给出了同样的问题。我正在使用g

  • 实际上,我正在开发一个带有Spring引导的restful API,我使用失眠作为客户端来测试对我的实体所做的修改。使用tomcat运行应用程序时,会显示错误消息: 无法启动应用程序 说明: 配置DataSource失败:未指定url属性,无法配置嵌入式数据源。 原因:无法确定合适的驱动程序类别。 我在文件“application.properties”中进行了必要的配置,并在pom.xml文件中

  • 我正在尝试将Postgres DB连接到我的Spring Boot应用程序,但出现以下错误: 配置数据源失败:未指定“url”属性,无法配置嵌入式数据源。原因:未能确定合适的驱动类< BR>动作: 考虑如下:如果你想要一个嵌入式数据库(H2,HSQL或DeBy),请把它放在类路径上。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有激活的配置文件)。 application.yaml

  • 我正在使用SpringBootJPA创建一个应用程序,我正在使用MySQL作为数据库。 以下是我的申请表。性质 我添加了以下依赖项 当我签入调试日志时,我可以在我的类路径中看到mysql java连接器,但仍然会出现以下错误 2019-07-29 10:03:00.742信息10356---[主要]o.a.c.c.c.c。[雄猫]。[本地主机]。[/]:初始化Spring嵌入式WebApplica