java Springboot外部文件数据库配置
我有申请。具有该代码的属性:
spring.config.additional-location=file:///C:/Users/user/Desktop/project/cfg.properties
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.hibernate.ddl-auto=validate
spring.jpa.show-sql=true
在cfg。属性看起来是这样的:
spring.datasource.url=jdbc:oracle:thin:@correctDbUrl
spring.datasource.username=user
spring.datasource.password=pass
我认为这条路有问题——它不能在项目之外吗?或者发生了什么?这是一个错误(url是正确的,直接放在application.properties中时有效):
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine suitable jdbc url
格雷德尔:
buildscript {
ext {
springBootVersion = '2.0.3.RELEASE'
}
repositories {
maven { url "someRepository" }
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.abc'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
maven { url "someRepository" }
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-web')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
compile(group: 'com.hynnet', name: 'oracle-driver-ojdbc6', version: '12.1.0.1')
compile("org.springframework.boot:spring-boot-starter-data-jpa")
}
# 1 楼答案
设置以下环境变量
您可以从属性文件中删除“spring.config.additional location”