java - 将 Spring Boot 连接到 SQL Server Express
问题描述
我尝试将我的 gradle Spring Boot 应用程序连接到正在运行的 SQL Server Express 安装。
我的配置是
spring.datasource.url=jdbc:sqlserver://localhost;InstanceName=SQLEXPRESS;databaseName=testDB;integratedsecurity=true
spring.datasource.username=SpringBootUser
spring.datasource.password=testPassword123
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.show-sql=true
spring.jpa.hibernate.dialect=org.hibernate.dialect.SQLServerDialect
spring.jpa.hibernate.ddl-auto = validate
build.grade 具有这些依赖项:
plugins {
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-hateoas'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc'
annotationProcessor 'org.projectlombok:lombok'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}
但我得到的只是这些信息:
原因:org.hibernate.service.spi.ServiceException:无法创建请求的服务 [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
原因:org.hibernate.HibernateException:当未设置“hibernate.dialect”时,对 DialectResolutionInfo 的访问不能为空
解决方案
确保你的类路径中有一个 application.properties。您的应用程序似乎无法加载您的配置文件。
推荐阅读
- c - 将inotify“事件”的对象保存在c中的数组中
- powershell - Powershell Script,在不知道电子邮件地址的情况下向脚本用户发送电子邮件(通过 Outlook)
- php - 将文件从远程服务器上的根目录包含到子域
- biopython - 如何获取神秘序列的 PDB id?
- r - 如何在 R 中使用相同的条件更改多个列?
- docker - “颤振测试”在 docker 映像上失败,但在本地成功
- html - 单选按钮的“值”属性的含义
- python-3.x - 如何获取网页抓取的链接
- azure-devops - Azure DevOps Pipeline 的另一个说明:-d--- 和 -a--- 模式
- asp.net - 程序集使用 'System.Runtime' 版本 = 4.2.2.0,它的版本高于引用的程序集 'System.Runtime' 版本 = 4.1.2.0