使用 Windows 身份验证从 Spring 启动应用程序连接到 MSSQL [英] Connect to MSSQL from Spring boot application using windows authentication

查看:40
本文介绍了使用 Windows 身份验证从 Spring 启动应用程序连接到 MSSQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用以下属性从 Java Spring Boot 应用程序连接到远程 Mssql 服务器:

I am currently using the below properties to connect to a remotely Mssql server from Java spring boot application:

spring.datasource.url=jdbc:sqlserver://ip\\domain;databaseName=name
spring.datasource.username=abc
spring.datasource.password=def
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver

该应用程序可从 windows 和 unix 服务器运行.我现在需要开始使用 Windows 身份验证而不是 db 凭据.这已经从 MSSQL 端配置和支持.从 Java spring boot 这不起作用.我试图添加到 url:integratedSecurity=true 它说它找不到 dll.我将 sqljdbc_auth.dll 添加到 java jre bin 文件夹,但它不起作用.

The application runs from both windows and unix servers. I need now to start using the windows authentication instead of the db credentials. This is already configured and supported from MSSQL side. From Java spring boot this is not working. I tried to add to the url: integratedSecurity=true it said it cannot find a dll. I added sqljdbc_auth.dll to java jre bin folder and it didnt work.

推荐答案

我正在研究 MS SQL Server 2016、Hibernate 5.3.7.Final 和 Spring bot 2.2.0.对我来说,将此行添加到属性中有效:(没有 jtds!)

I'm working on MS SQL Server 2016, Hibernate 5.3.7.Final and Spring bot 2.2.0. For me, adding this line to properties worked: (without jtds!)

spring.datasource.url=jdbc:servername;databasename=your_db_name;integratedSecurity=true

您可能还需要这些属性:

You may also need these properties:

spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect

如果您遇到java.library.path 中没有 sqljdbc_auth"的问题.你可以参考这个答案no sqljdbc_auth.

And if you encounter a problem with "no sqljdbc_auth in java.library.path". You may refer to this answer no sqljdbc_auth.

这篇关于使用 Windows 身份验证从 Spring 启动应用程序连接到 MSSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆