简体   繁体   English

Spring Boot 2.2.2 数据源 URL 不适用于 SQL Server 2019

[英]Spring Boot 2.2.2 Datasource URL not working for SQL Server 2019

I'm trying to doing a test development with Spring on SQL Server 2019, but all I get is the Datasource url attribute issue.我正在尝试在 SQL Server 2019 上使用 Spring 进行测试开发,但我得到的只是数据源 url 属性问题。

Description:

Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

Reason: Failed to determine a suitable driver class

As for my yml configration I don't think I set something wrong至于我的 yml 配置,我认为我没有设置错误

spring:
  datasource:
    url: jdbc:sqlserver://localhost:1433;databaseName=yap_test
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    username: 'yap_user'
    password: 'P@ssw0rd'
  jpa:
    hibernate:
      ddl-auto: update
    properties:
      hibernate:
        show_sql: false
        format_sql: false
        dialect: org.hibernate.dialect.SQLServer2012Dialect
        use_nationalized_character_data: true
      org:
        hibernate:
          envers:
            audit_table_prefix: AUD_
            audit_table_suffix: ''
            revision_field_name: REVISION_ID
            revision_type_field_name: REVISION_TYPE
            store_data_at_delete: true

for the JDBC Driver i'm using mssql-jdbc-8.2.2.jre8对于 JDBC 驱动程序,我使用的是 mssql-jdbc-8.2.2.jre8

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>8.2.2.jre8</version>
</dependency>

I hope someone can help me figure out what's my configuration problem我希望有人能帮我弄清楚我的配置问题是什么

Everything looks fine.一切看起来都很好。 there is no problem with property file.属性文件没有问题。

1st of all try to check whether "mssql" jar is there or not in your local maven repository.首先,尝试检查本地 Maven 存储库中是否存在“mssql” jar。

if it's there then update your property file as below:--如果它在那里然后更新您的属性文件如下: -

spring.datasource.driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver

In your Case it should be:--(yml file)在您的情况下,它应该是:--(yml 文件)

spring:
  datasource:
    driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver

if it's not there:--如果它不在那里:--

solution :- give the mssql JAR path in the pom then run解决方案:- 在 pom 中给出 mssql JAR 路径然后运行

我实际上在 jar 重新打包期间添加了 exclude 任何 YML 文件,这就是为什么每次我尝试在本地运行它时都找不到 url 属性的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring boot 2配置Sql server 2019数据库报错 - Error when configuring the Sql server 2019 database in Spring boot 2 Spring boot v 2.2.2.RELEASE 中的异常处理程序不工作? - Exception Handler in Spring boot v 2.2.2.RELEASE not working? Spring Boot 2.2.2 中的 AuthenticationManager 注入失败 - AuthenticationManager injection failed in spring boot 2.2.2 Heroku 是否重写了 Spring Boot 的 spring.datasource.url、spring.datasource.username 和 spring.datasource.password 属性? - Is Heroku rewrites Spring Boot's spring.datasource.url, spring.datasource.username and spring.datasource.password properties? 升级到 Spring Boot 2.2.2.RELEASE + Thymeleaf 3.0.11.RELEASE,thymeleaf/layout 停止工作 - Upgrading to Spring Boot 2.2.2.RELEASE + Thymeleaf 3.0.11.RELEASE, thymeleaf/layout stopped working 为SQL Server创建DataSource的Spring错误 - Spring error creating DataSource for SQL Server Spring boot 无法配置数据源:未指定“url”属性 - Spring boot Failed to configure a DataSource: 'url' attribute is not specified Spring启动会忽略application.yml中的数据源URL - Spring boot ignores datasource url in application.yml 无法配置数据源:未使用 Spring Boot 指定“url”属性 - Failed to configure a DataSource: 'url' attribute is not specified using Spring Boot Spring Boot Multiple Datasource - Spring Boot Multiple Datasource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM