【发布时间】:2020-03-27 12:07:09
【问题描述】:
我是 Java/spring boot 的新手,我正在尝试使用 google 的云 SQL 作为我的项目的数据库。我已经下载了谷歌代理并使用谷歌云 SDK 进行了身份验证。当我启动代理并使用 SSMS 连接时,它会连接并正常工作。问题是当我尝试通过 spring boot 应用程序连接时出现错误。我不确定我是否在应用程序属性中遗漏了某些东西,或者忘记了导入依赖项或类似的东西。任何帮助,将不胜感激!我在下面包含了 applications.properties、build.gradle 和错误。谢谢!
Application.properties
spring.jpa.hibernate.ddl-auto=create spring.datasource.url=jdbc:mysql://127.0.0.1:1433/{DBNAME} spring.datasource.username={DMUSERNAME} spring.datasource.password={DMPASSWORD}
build.gradle
id 'org.springframework.boot' version '2.2.1.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = '{GROUPNAME}'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'https://repo.spring.io/milestone' }
}
ext {
set('springCloudVersion', "Hoxton.RC2")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
implementation 'org.springframework.cloud:spring-cloud-gcp-starter'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtime 'mysql:mysql-connector-java'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
test {
useJUnitPlatform()
}
错误
Caused by: java.net.ConnectException: Connection refused: no further information
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service
[org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when
'hibernate.dialect' not set
Process 'command 'C:/Program Files/Java/jdk-13.0.1/bin/java.exe'' finished with non-zero exit value 1
【问题讨论】:
标签: mysql spring-boot google-cloud-platform google-cloud-storage google-cloud-sql