Spring 在 Windows 身份验证模式下引导连接到 SQL 服务器

Spring Boot connection to SQL Server in Windows Authentication mode

我正在尝试以 Windows 身份验证模式连接到 SQL 服务器,这是我的数据库配置:

database.name= DatabaseName spring.datasource.url=jdbc:sqlserver://1.2.3.4:11111;DatabaseName=${database.name};integratedSecurity = true;
 spring.datasource.username=user
 spring.datasource.password=passw
spring.datasource.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver 

我遇到了这些错误:

否定匹配:


AVSSimulatorServerApplication:
      Did not match:
         - @ConditionalOnProperty (spring.application.name=avs-simulator-service) found different value in property 'spring.application.name' (OnPropertyCondition)

ActiveMQAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.ActiveMQConnectionFactory' (OnClassCondition)

   AopAutoConfiguration.JdkDynamicAutoProxyConfiguration:
      Did not match:
         - @ConditionalOnProperty (spring.aop.proxy-target-class=false) found different value in property 'proxy-target-class' (OnPropertyCondition)

   ArtemisAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required classes 'javax.jms.ConnectionFactory', 'org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory' (OnClassCondition)

   AsyncCustomAutoConfiguration:
      Did not match:
         - @ConditionalOnBean (types: org.springframework.scheduling.annotation.AsyncConfigurer; SearchStrategy: all) did not find any beans (OnBeanCondition)
      Matched:
         - @ConditionalOnProperty (spring.sleuth.async.enabled) matched (OnPropertyCondition)
.......

Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'user'. ClientConnectionId:ce912574-1f20-4843-9b43-01820e67cf54

Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'user'. ClientConnectionId:ce912574-1f20-4843-9b43-01820e67cf54

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.HashMap]: 

................

有人知道在这种情况下我该怎么办吗?

我找到了解决方法,只是为了使用

integratedSecurity = false; 

而不是

integratedSecurity = true; 

所以在这种情况下连接字符串将是:

database.name= DatabaseName spring.datasource.url=jdbc:sqlserver://1.2.3.4:11111;DatabaseName=${database.name};**integratedSecurity = false**;.

为什么要使用integratedSecurity = false? 原因在这里:

Integrated Security When false, User ID and Password are specified in the connection. When true, the current Windows account credentials are used for authentication.