如何通过standalone.xml 配置将 PostgreSql 连接到 Keycloak

Posted

技术标签:

【中文标题】如何通过standalone.xml 配置将 PostgreSql 连接到 Keycloak【英文标题】:How can I connect PostgreSql to Keycloak via standalone.xml configurations 【发布时间】:2021-06-22 13:20:16 【问题描述】:

安装“keycloak-12.0.4”后。我能够在默认的 keycloak H2 数据库上成功运行服务器。但是,当我尝试添加 POSTGRESQL“数据源”时,出现连接错误。

以下是我采取的步骤:

    我在 Docker 上运行了一个 POSTGRESQL 数据库服务器

docker run -d -p 5432:5432 --name postgres-keycloak --restart unless-stopped -e "DB_TYPE=postgres" -e "DB_HOST=hs-psql13-prod" -e "DB_PORT=5432" - e "DB_USER=keycloak_user" -e "DB_PASS=MyPassword" -e "DB_NAME=keycloak_dev" emanoid/postgres

    接下来我在“keycloak-12.0.4/modules/system/layers/keycloak/org”目录中添加了一个空白的“postgresql/main/module.xml”文件 然后我从https://jdbc.postgresql.org/download.html 下载了一个JDBC postgres 驱动程序。我专门下载了postgresql-42.2.19。这个驱动也被放到了“keycloak-12.0.4/modules/system/layers/keycloak/org/postgresql/main/”目录下。 我使用以下详细信息更新了“module.xml”文件:
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="org.postgresql">
    <resources>
        <resource-root path="postgresql-42.2.19.jar"/>
    </resources>
    <dependencies>
        <module name="javax.api"/>
        <module name="javax.transaction.api"/>
    </dependencies>
</module>
    为了声明和加载我的 JDBC 驱动程序,我转到“keycloak-12.0.4/standalone/configuration/standalone.xml”文件并将以下配置添加到相应的标签中:
<drivers>
    <driver name="postgresql" module="org.postgresql">
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
    </driver>
    <driver name="h2" module="com.h2database.h2">
        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
    </driver>
</drivers>
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true"> 
    <connection-url>jdbc:postgresql://hs-psql13-prod/5432/keycloak_dev</connection-url>
    <driver>postgresql</driver>
    <pool>
        <max-pool-size>20</max-pool-size>
    </pool>
    <security>
        <user-name>keycloak_user</user-name>
         <password>MyPassword</password>
    </security>
</datasource>
<spi name="connectionsJpa">
    <provider name="default" enabled="true">
        <properties>
            <property name="dataSource" value="java:jboss/datasources/KeycloakDS"/>
            <property name="initializeEmpty" value="false"/>
            <property name="migrationStrategy" value="manual"/>
            <property name="migrationExport" value="$jboss.home.dir/keycloak-database-update.sql"/>
        </properties>
    </provider>
</spi>
    接下来,我通过导航到“keycloak-12.0.4/bin/”和standalone.bat -Djboss.socket.binding.port-offset=100 来运行服务器,让服务器在端口 8180 上运行。

采取这些步骤后:这是终端错误消息:

C:\Users\eolatunde\Desktop\Learning Languages\Authentication & Registration\Keycloak\keycloak-12.0.4\bin>standalone.bat -Djboss.socket.binding.port-offset=100
Calling "C:\Users\eolatunde\Desktop\Learning Languages\Authentication & Registration\Keycloak\keycloak-12.0.4\bin\standalone.conf.bat"
Setting JAVA property to "C:\Program Files\Java\jdk-12.0.1\bin\java"
===============================================================================

  JBoss Bootstrap Environment

  JBOSS_HOME: "C:\Users\eolatunde\Desktop\Learning Languages\Authentication & Registration\Keycloak\keycloak-12.0.4"

  JAVA: "C:\Program Files\Java\jdk-12.0.1\bin\java"

  JAVA_OPTS: "-Dprogram.name=standalone.bat -Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman  --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.unsupported/sun.reflect=ALL-UNNAMED"

===============================================================================

14:51:51,601 INFO  [org.jboss.modules] (main) JBoss Modules version 1.10.2.Final
14:51:51,976 INFO  [org.jboss.msc] (main) JBoss MSC version 1.4.12.Final
14:51:51,984 INFO  [org.jboss.threads] (main) JBoss Threads version 2.4.0.Final
14:51:52,084 INFO  [org.jboss.as] (MSC service thread 1-2) WFLYSRV0049: Keycloak 12.0.4 (WildFly Core 13.0.3.Final) starting
......
14:51:53,187 INFO  [org.jboss.as.connector] (MSC service thread 1-5) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.4.23.Final)
14:51:53,194 INFO  [org.wildfly.extension.microprofile.metrics.smallrye] (ServerService Thread Pool -- 53) WFLYMETRICS0001: Activating Eclipse MicroProfile Metrics Subsystem
14:51:53,223 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0003: Undertow 2.2.2.Final starting
14:51:53,230 INFO  [org.jboss.as.naming] (MSC service thread 1-6) WFLYNAM0003: Starting Naming Service
14:51:53,232 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 32) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 42.2)
14:51:53,243 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-8) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default]
14:51:53,251 WARN  [org.wildfly.clustering.web.undertow] (ServerService Thread Pool -- 54) WFLYCLWEBUT0007: No routing provider found for default-server; using legacy provider based on static configuration
......
14:51:55,324 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 64) WFLYCLINF0002: Started authorizationRevisions cache from keycloak container
14:51:55,325 INFO  [org.keycloak.connections.infinispan.DefaultInfinispanConnectionProviderFactory] (ServerService Thread Pool -- 64) Node name: hs-wkst11, Site name: null
14:51:57,138 INFO  [org.keycloak.connections.jpa.DefaultJpaConnectionProviderFactory] (ServerService Thread Pool -- 64) Database info: databaseUrl=jdbc:postgresql://hs-psql13-prod:5432/keycloak_dev, databaseUser=keycloak_user, databaseProduct=PostgreSQL 13.1, databaseDriver=PostgreSQL JDBC Driver 42.2.19
14:52:02,154 INFO  [org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider] (ServerService Thread Pool -- 64) Initializing database schema. Using changelog META-INF/jpa-changelog-master.xml
14:52:02,879 FATAL [org.keycloak.services] (ServerService Thread Pool -- 64) Error during startup: org.keycloak.ServerStartupError: Database not initialized, please initialize database with C:\Users\eolatunde\Desktop\Learning Languages\Authentication & Registration\Keycloak\keycloak-12.0.4\keycloak-database-update.sql

14:52:02,882 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002225: Deploying javax.ws.rs.core.Application: class org.keycloak.services.resources.KeycloakApplication
14:52:02,884 INFO  [org.jboss.as.server] (Thread-1) WFLYSRV0220: Server shutdown has been requested via an OS signal
14:52:02,884 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002200: Adding class resource org.keycloak.services.resources.JsResource from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,884 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002200: Adding class resource org.keycloak.services.resources.ThemeResource from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,885 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002205: Adding provider class org.keycloak.services.filters.KeycloakSecurityHeadersFilter from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,886 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002205: Adding provider class org.keycloak.services.error.KeycloakErrorHandler from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,886 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.RealmsResource from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,887 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.WelcomeResource from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,889 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.RobotsResource from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,890 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002210: Adding provider singleton org.keycloak.services.util.ObjectMapperResolver from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,890 INFO  [org.jboss.resteasy.resteasy_jaxrs.i18n] (ServerService Thread Pool -- 64) RESTEASY002220: Adding singleton resource org.keycloak.services.resources.admin.AdminRoot from Application class org.keycloak.services.resources.KeycloakApplication
14:52:02,896 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0010: Unbound data source [java:jboss/datasources/KeycloakDS]
14:52:02,902 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-6) WFLYMAIL0002: Unbound mail session [java:jboss/mail/Default]
14:52:02,902 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0008: Undertow HTTPS listener https suspending
14:52:02,911 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-7) WFLYJCA0019: Stopped Driver service with driver-name = postgresql
14:52:02,913 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) WFLYUT0007: Undertow HTTPS listener https stopped, was bound to 127.0.0.1:8543
14:52:02,955 INFO  [org.hibernate.validator.internal.util.Version] (ServerService Thread Pool -- 64) HV000001: Hibernate Validator 6.0.21.Final
14:52:02,967 INFO  [org.jboss.resteasy.plugins.validation.i18n] (ServerService Thread Pool -- 64) RESTEASY008550: Unable to find CDI supporting ValidatorFactory. Using default ValidatorFactory
14:52:03,060 ERROR [org.jboss.as.txn] (ServerService Thread Pool -- 64) WFLYTX0003: APPLICATION ERROR: transaction still active in request with status 0
14:52:03,061 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0021: Registered web context: '/auth' for server 'default-server'
14:52:03,063 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0022: Unregistered web context: '/auth' from server 'default-server'
14:52:03,067 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) WFLYJCA0010: Unbound data source [java:jboss/datasources/ExampleDS]
14:52:03,068 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0019: Stopped Driver service with driver-name = h2
14:52:03,070 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-7) WFLYUT0019: Host default-host stopping
14:52:03,073 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 61) WFLYCLINF0003: Stopped offlineClientSessions cache from keycloak container
14:52:03,073 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 58) WFLYCLINF0003: Stopped clientSessions cache from keycloak container
14:52:03,073 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 59) WFLYCLINF0003: Stopped work cache from keycloak container
14:52:03,074 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 66) WFLYCLINF0003: Stopped authenticationSessions cache from keycloak container
14:52:03,074 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 56) WFLYCLINF0003: Stopped sessions cache from keycloak container
14:52:03,074 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 57) WFLYCLINF0003: Stopped actionTokens cache from keycloak container
14:52:03,074 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 65) WFLYCLINF0003: Stopped offlineSessions cache from keycloak container
14:52:03,073 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 67) WFLYCLINF0003: Stopped loginFailures cache from keycloak container
14:52:03,078 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0008: Undertow HTTP listener default suspending
14:52:03,076 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0003: Stopped users cache from keycloak container
14:52:03,076 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 68) WFLYCLINF0003: Stopped authorization cache from keycloak container
14:52:03,076 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 63) WFLYCLINF0003: Stopped realms cache from keycloak container
14:52:03,075 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 60) WFLYCLINF0003: Stopped keys cache from keycloak container
14:52:03,081 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0007: Undertow HTTP listener default stopped, was bound to 127.0.0.1:8180
14:52:03,081 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 64) WFLYCLINF0003: Stopped http-remoting-connector cache from ejb container
14:52:03,082 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0028: Stopped deployment keycloak-server.war (runtime-name: keycloak-server.war) in 196ms
14:52:03,084 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0004: Undertow 2.2.2.Final stopping
14:52:03,084 INFO  [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 60) Stopping cache manager null on null
14:52:03,084 INFO  [org.infinispan.manager.DefaultCacheManager] (ServerService Thread Pool -- 64) Stopping cache manager null on null
14:52:03,094 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException
        at org.wildfly.extension.microprofile.metrics-smallrye@21.0.2.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:89)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:1005)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:744)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:468)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1415)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:529)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:477)
        at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:451)
        at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:404)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
        at java.base/java.lang.Thread.run(Thread.java:835)

14:52:03,097 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 26) WFLYCTL0403: Unexpected failure during execution of the following operation(s): [
    "operation" => "add",
    "address" => [("subsystem" => "security-manager")]
, 
    "operation" => "add",
    "address" => [
        ("subsystem" => "security-manager"),
        ("deployment-permissions" => "default")
    ],
    "maximum-permissions" => ["class" => "java.security.AllPermission"]
]: java.lang.RuntimeException: WFLYCTL0195: Interrupted awaiting transaction commit or rollback
        at ....... org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:835)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)

14:52:03,097 ERROR [org.jboss.as.controller.management-operation] (ServerService Thread Pool -- 7) WFLYCTL0403: Unexpected failure during execution of the following operation(s): [
    "operation" => "add",
    "address" => [("subsystem" => "jpa")],
    "default-datasource" => "",
    "default-extended-persistence-inheritance" => "DEEP"
]: java.lang.RuntimeException: WFLYCTL0195: Interrupted awaiting transaction commit or rollback
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTransactionControl.operationPrepared(ParallelBootOperationStepHandler.java:458)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.ModelController$OperationTransactionControl.operationPrepared(ModelController.java:131)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeDoneStage(AbstractOperationContext.java:839)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:770)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:468)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.ParallelBootOperationStepHandler$ParallelBootTask.run(ParallelBootOperationStepHandler.java:384)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Thread.java:835)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.JBossThread.run(JBossThread.java:513)

Press any key to continue . . .
C:\Users\eolatunde\Desktop\Learning Languages\Authentication & Registration\Keycloak\keycloak-12.0.4\bin>

错误信息是:

14:52:03,094 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("add") failed - address: ([("subsystem" => "microprofile-metrics-smallrye")]): java.lang.NullPointerException
        at org.wildfly.extension.microprofile.metrics-smallrye@21.0.2.Final//org.wildfly.extension.microprofile.metrics.MicroProfileMetricsSubsystemAdd$2.execute(MicroProfileMetricsSubsystemAdd.java:89)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:1005)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.processStages(AbstractOperationContext.java:744)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractOperationContext.executeOperation(AbstractOperationContext.java:468)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.OperationContextImpl.executeOperation(OperationContextImpl.java:1415)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.ModelControllerImpl.boot(ModelControllerImpl.java:529)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:515)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService.boot(AbstractControllerService.java:477)
        at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:451)
        at org.jboss.as.server@13.0.3.Final//org.jboss.as.server.ServerService.boot(ServerService.java:404)
        at org.jboss.as.controller@13.0.3.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
        at java.base/java.lang.Thread.run(Thread.java:835)

我已尝试以下方法来解决此问题:

使用默认 H2 数据库运行服务器 - 效果很好 下载其他 JDBC 驱动程序 - 产生类似错误 确保 Postgres 数据库正在运行SQL Shell Database Listing

我期待任何有助于解决此问题的贡献。我的 *** 浏览、Google 搜索和在线论坛推荐无助于解决此问题。谢谢!

【问题讨论】:

【参考方案1】:

要解决该错误,应更新“standalone.xml”文件。具体来说,名称为 connectionsJpa 的“spi”标签应该从

更新
<spi name="connectionsJpa">
    <provider name="default" enabled="true">
        <properties>
            <property name="dataSource" value="java:jboss/datasources/KeycloakDS"/>
            <property name="initializeEmpty" value="false"/>
            <property name="migrationStrategy" value="manual"/>
            <property name="migrationExport" value="$jboss.home.dir/keycloak-database-update.sql"/>
        </properties>
    </provider>
</spi>

<spi name="connectionsJpa">
    <provider name="default" enabled="true">
        <properties>
            <property name="dataSource" value="java:jboss/datasources/KeycloakDS"/>
            <property name="initializeEmpty" value="false"/>
            <property name="migrationStrategy" value="update"/>
            <property name="migrationExport" value="$jboss.home.dir/keycloak-database-update.sql"/>
        </properties>
    </provider>
</spi>

这是因为,使用手动时,脚本希望您手动运行某个 SQL 配置文件,否则可以通过将值参数从“手动”更改为“更新”来自动运行。

更新此文档后,我能够将 keycloak 连接到我的数据库!我希望这对任何人都有帮助!

【讨论】:

以上是关于如何通过standalone.xml 配置将 PostgreSql 连接到 Keycloak的主要内容,如果未能解决你的问题,请参考以下文章

Spring Boot:使用 WildFly 的standalone.xml 中的数据库配置

如何在 JBoss 7.0 中使用standalone.xml 分离应用程序日志

Wildfly 9:通过编程[max-post-size]而不是修改standalone.xml来设置Undertow

如何将PO.5配置成上拉输入

Boss7 Standalone模式开发配置

如果我不使用某些模块,是不是必须将所有模块都包含在 wildfly10.1.0 Standalone.xml 中?