![](/img/trans.png)
[英]Spring unable to autowire ConnectionFactory for RabbitMQ
[英]IllegalStateException: Unable to create a ConnectionFactory for
當我嘗試使用如下非反應性方法時,我能夠毫無問題地建立連接。
spring.datasource.url=jdbc:sqlserver://AAAAA1011.na.app.corp\\bbbb;databaseName=mydb;integratedSecurity=true;authenticationScheme=JavaKerberos
但是當我嘗試使用 Reactive R2dbc 和 MsSql 服務器方法時,如下所示,然后我面臨異常,下面是代碼:
@Bean
@Override
public ConnectionFactory connectionFactory() {
ConnectionFactory connectionFactory = ConnectionFactories.get(ConnectionFactoryOptions.builder()
.option(ConnectionFactoryOptions.DRIVER, "mssql")
.option(ConnectionFactoryOptions.HOST, "AAAAA1011.na.app.corp/bbbb")
.option(ConnectionFactoryOptions.DATABASE, "mydb")
.option(ConnectionFactoryOptions.USER, "NA\\user")
.option(Option.valueOf("integratedSecurity"), true)
.option(Option.valueOf("authenticationScheme"), "JavaKerberos")
.build());
return connectionFactory;
}`
異常堆棧跟蹤:
org.springframework.beans.BeanInstantiationException: Failed to instantiate [io.r2dbc.spi.ConnectionFactory]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.IllegalStateException: Unable to create a ConnectionFactory for 'ConnectionFactoryOptions{options={database=mydb, host=AAAAA1011.na.app.corp/bbbb, driver=mssql, authenticationScheme=JavaKerberos, integratedSecurity=true, user=NA\user}}'. Available drivers: [ pool, sqlserver ]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.23.jar:5.3.23]
我也找到了這個鏈接: https://github.com/r2dbc/r2dbc-mssql/issues/101
,提到r2dbc似乎不支持Kerberos,但那是寫在2019年的,現在已經3年了,不確定上面是否工作與否。
如果有人知道上述問題,你能幫幫我嗎..
從異常信息來看,連接問題是由驅動程序設置引起的。
可用的驅動程序:[ pool, sqlserver ]
嘗試將.option(ConnectionFactoryOptions.DRIVER, "mssql")
更改為以下內容:
.option(ConnectionFactoryOptions.DRIVER, "sqlserver")
我對 R2dbc/MSSQL 中的 Kerberos 支持知之甚少,請根據官方文檔更新自己。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.