gpt4 book ai didi

java - 驱动程序 oracle.jdbc.OracleDriver 声称不接受 jdbcUrl

转载 作者:行者123 更新时间:2023-11-29 08:22:50 34 4
gpt4 key购买 nike

我正在尝试连接到 Oracle 数据库。

当我尝试通过简单的 jdbc 连接进行连接时,它起作用了。

Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@chbsux0097.eu.novartis.net:1530:AD14", "xxxx", "xxxxx")

但是,它不适用于 Spring-boot 并出现以下错误

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-05-09 12:48:51.189 ERROR 16236 --- [ main] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactory' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityManagerFactoryBuilder' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unsatisfied dependency expressed through method 'entityManagerFactoryBuilder' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaVendorAdapter' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.orm.jpa.JpaVendorAdapter]: Factory method 'jpaVendorAdapter' threw exception; nested exception is java.lang.RuntimeException: Driver oracle.jdbc.OracleDriver claims to not accept jdbcUrl, jdbc:oracle:thin@chbsux0097.eu.novartis.net:1530:AD14
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:769) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:509) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]

application.properties

spring.datasource.username=xx
spring.datasource.password=xxxxx
spring.datasource.url=jdbc:oracle:thin@chbsux0097.eu.novartis.net:1530:AD14
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

最佳答案

您在配置中 thin 之后的 URL 中缺少一个冒号。它必须是:

spring.datasource.url=jdbc:oracle:thin:@chbsux0097.eu.novartis.net:1530:AD14

请注意,您的工作简化示例中存在冒号。

关于java - 驱动程序 oracle.jdbc.OracleDriver 声称不接受 jdbcUrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56054353/

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