java - 在 Wildfly 中配置无密码 Azure SQL

标签 java sql-server azure wildfly password-less

我正在尝试配置部署到 Wildfly 23 的应用程序以使用托管标识连接到 Azure SQL,但很难想象它的工作原理。 互联网上有大量关于如何使用无密码连接连接到 Azure 托管数据库的文章和操作方法。其中大多数需要将 azure-identity.jar 包含到类路径中,并在 jdbc 连接字符串中使用 authentication=ActiveDirectoryMSI 选项。 但是,我的应用程序使用疯狂配置的连接池,因此将 azure-identity.jar 添加到我的应用程序将无济于事。根据我的理解,我需要使 azure-identity.jar 可用于 wildfly,但我不知道该怎么做。一个想法是将其注册为模块,我还没有尝试过,因为我需要以某种方式管理 jar 的依赖关系。

到目前为止,我更改了独立文件以包含数据源

<datasource jndi-name="java:/jdbc/passwordless" pool-name="pwls-ds" enabled="true">
                    <connection-url>jdbc:sqlserver://xxxxx.database.windows.net:1433;database=aaa;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;authentication=ActiveDirectoryMSI</connection-url>
                    <driver-class>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver-class>
                    <driver>mssql-jdbc-12.4.1.jre11.jar</driver>
                    <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
                    <pool>
                        <min-pool-size>2</min-pool-size>
                        <initial-pool-size>5</initial-pool-size>
                        <max-pool-size>20</max-pool-size>
                    </pool>
                </datasource>

尝试测试连接时出现以下异常

com.microsoft.sqlserver.jdbc.SQLServerException: Failed to load MSAL4J Java library for performing ActiveDirectoryManagedIdentity authentication

任何提示/帮助都会受到赞赏。

最佳答案

添加MSAL4J包括类路径上的所有依赖项

关于java - 在 Wildfly 中配置无密码 Azure SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/77169366/

相关文章:

azure - windows azure上传文件路径错误: 'Could not find file... '

java - 当RestApi有Spring的ResponseEntity<void>有返回值时,它返回ClientProtocolException

java - JSF - selectManyListbox 附带已选择的项目

sql - 会计部第二高薪资如何拿?

sql-server - 选择字段时不使用索引

c# - 在 SQL Server 中存储、检索和验证密码 (SecureString)

azure - 服务总线队列的噩梦。消息消失了

powershell - Azure key 保管库 : Secret not found error

java - 使用估算器在 Java 中加载/提供 tensorflow 模型时出现问题

java - 将 Arraylist 中的每个 Integer 设置为特定值