我正在使用Spring Boot 1.5.10.RELEASE,Oracle数据库12c,Gradle 4.6
档案application.properties
server.port=8081
spring.datasource.url=jdbc:oracle:thin:@localhost:1521:xe
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.username=accounting
spring.datasource.password=123456
spring.datasource.testWhileIdle=true
spring.datasource.validationQuery=SELECT 1
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.Oracle12cDialect
档案build.gradle
buildscript {
ext {
springBootVersion = '1.5.10.RELEASE'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'
group = 'com.donhuvy'
version = '1.0.0-SNAPSHOT'
jar.archiveName = "spring_boot_oracle-1.0.0-SNAPSHOT.jar"
sourceCompatibility = 9
repositories {
mavenLocal()
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
configurations {
providedRuntime
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-jpa') {
exclude group: 'org.apache.tomcat', module: 'tomcat-jdbc'
}
runtime('com.oracle:ojdbc7:12.1.0.1')
}
错误
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
Process finished with exit code 1
虽然我想使用真正的数据库服务器,Spring Boot想要嵌入数据库,如何修复它?
答案 0 :(得分:0)
在我看来,你错过了对oracle JDBC驱动程序的依赖。 Spring Data JPA仅提供抽象。您仍然需要单独下载oracle JDBC驱动程序。似乎它不在maven存储库中。
请尝试遵循此link