Java SQL Server JDBC 的驱动程序类名称是什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/52715797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 00:35:49  来源:igfitidea点击:

What's the driver class name for SQL Server JDBC

javasql-serverspring

提问by Clyde Barrow

I want to connect my Java SpringBoot app to SQL Server and I get the information that spring cannot load driver class. I tried:

我想将我的 Java SpringBoot 应用程序连接到 SQL Server 并且我得到 spring 无法加载驱动程序类的信息。我试过:

spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver

and

spring.datasource.driver-class-name=com.microsoft.jdbc.sqlserver.SQLServerDriver

But both did not work, here is my maven dependency

但是两者都不起作用,这是我的 Maven 依赖项

<dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>mssql-jdbc</artifactId>
    <version>7.0.0.jre8</version>
    <scope>test</scope>
</dependency>

采纳答案by Shepard62700FR

According to this web page, the correct property is spring.datasource.driverClassName.

根据此网页,正确的属性是spring.datasource.driverClassName.

So, the full connection string should be:

所以,完整的连接字符串应该是:

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