我正在尝试将Spring Boot应用程序部署到使用外部Oracle数据源的PCF,该应用程序在本地运行良好。我已经在文件夹{projectroot} / jars中添加了ojdbc6.jar,并在我的maven pom.xml文件中对其进行了引用。我收到以下错误:
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT]
2019-01-17 05:01:11.315 ERROR 16 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] ***************************
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] APPLICATION FAILED TO START
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Description:
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Property: driverclassname
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Value: oracle.jdbc.OracleDriver
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Origin: "driverClassName" from property source "source"
2019-01-17T10:31:11.315+05:30 [APP/PROC/WEB/0] [OUT] Reason: Failed to load driver class oracle.jdbc.OracleDriver in either of HikariConfig class loader or Thread context classloader
我尝试使用mvn install cmd安装ojdbc6 jar:
mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.3 -Dpackaging=jar -Dfile=ojdbc6.jar -DgeneratePom=true
并将依赖项添加到我的pom文件中
我已经检查了最终的可部署jar,它在以下文件夹中包含ojdbc6.jar:BOOT-INF / lib
我的application.yml文件
spring:
datasource:
driverClassName: oracle.jdbc.OracleDriver
url: jdbc:oracle:thin:@dbhost:dbport:svcname
username: username
password: password
这是我的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>odata-example</groupId>
<artifactId>odata-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>odata-example</name>
<description>Odata POC for exposing data from DB using Annotation based EDM Objects</description>
<properties>
<java.version>1.8</java.version>
<version.olingo>2.0.8</version.olingo>
<lombok.version>1.16.18</lombok.version>
</properties>
<dependencies>
<!-- Spring related dependecies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<scope>system</scope>
<systemPath>${basedir}/jars/ojdbc6.jar</systemPath>
</dependency>
<!-- Odata related dependencies -->
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-api</artifactId>
<version>${version.olingo}</version>
</dependency>
<dependency>
<artifactId>olingo-odata2-api-annotation</artifactId>
<groupId>org.apache.olingo</groupId>
<type>jar</type>
<version>${version.olingo}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-core</artifactId>
<version>${version.olingo}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor-api</artifactId>
<version>${version.olingo}</version>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-annotation-processor-core</artifactId>
<version>${version.olingo}</version>
</dependency>
<!-- Other dependencies -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
这是从pcf连接到外部Oracle DB的正确方法,也是为什么BOOT-INF / lib中存在jar时找不到驱动程序类的原因。外部罐子是否在其他位置?
我是pcf的新手。