java - 使用 PCF 用户提供的服务创建数据源失败

标签 java spring-boot spring-data-jpa oracle12c cloud-foundry

我有一个 SpringBoot 应用程序,并将其部署在 PCF 中,其中应用程序尝试使用 PCF 用户提供的服务 连接 Oracle 12c 数据库,但它因此错误而失败无法确定合适的驱动程序类

build.gradle代码:

enter image description here

以下是我在 CUP 服务中使用的配置: enter image description here

服务绑定(bind)正常进行。我可以在环境变量中的VCAP_SERVICES下看到相同的详细信息。

错误: enter image description here

最佳答案

简短回答:我认为您希望 urioracle://..。去掉 jdbc: 部分。由 Java buildpack 注入(inject)的 Spring Autoreconfiguration 代码将查看 URI 上的前缀,因此它需要 oracle:// 才能知道它是 Oracle 链接。

长答案:您可能不想依赖注入(inject)的 Spring Autoreconfiguration。当它正常工作时,这很棒,但当它不工作时,可能很难理解它在做什么。

最好使用 Spring Cloud Connector 甚至更好,因为所有迹象都表明它会取代 Spring Cloud Connector,请使用 java-cfenv 。有关 java-cfenv 的详细信息,请参阅this blog post .

Spring Cloud Connector 与我上面提到的 Spring Autoreconfiguration 存在相同的问题,只不过它会非常清楚地告诉您它何时无法识别绑定(bind)服务。无论如何,如果您决定使用 SCC,请确保在 URI 中添加 oracle:// 前缀。

如果您使用java-cfenv,它会更加灵活,因此这实际上取决于您通过服务注入(inject)的属性和值。

希望有帮助!

关于java - 使用 PCF 用户提供的服务创建数据源失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57813192/

相关文章:

java - @SuppressWarnings 带注释的参数限定规则

java - 如何使用 jersey 将 header 信息作为键值对传递以使用休息服务

spring-boot - 交叉加入 Spring Boot 2.1.4.RELEASE 应用程序

PostgreSQl 在创建新实体时正确锁定

java - JSF + Primefaces : Problem with "rendered" components with ajax

java - 导航 View : Mark menu as dirty

java - 为什么 Gradle 'build' 任务不是最新的,即使源代码没有变化?

java - Spring Boot +百里叶;第:object+field in checkbox "arbitrarily" giving errors

mysql - JPA 一元运算符

spring - 使用 JPA 存储库上的 Spring-Data 可分页对象进行排序时出现重复结果