Key斗篷+postgresql配置



我试图用postgresqldb配置密钥斗篷服务器。在尝试了很多配置之后,我决定问这个问题。我有以下配置:module.xml,位于key斗篷/modules.org/postgresql/main中同样在该目录中,我放置了名为"postgresql-42.2.16.jar"的jdbc驱动程序

<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.1" name="org.postgresql">
<resources>
<resource-root path="postgresql-42.2.16.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>

standalone.xml,位于keyclope/stalone/configuration中在那个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>

数据源:

<datasources>
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true">
<connection-url>jdbc:postgres://192.168.99.100:5432/keycloak</connection-url>
<driver>postgresql</driver>
<pool>
<max-pool-size>20</max-pool-size>
</pool>
<security>
<user-name>keycloak</user-name>
<password>password</password>
</security>
</datasource>
<datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true" statistics-enabled="${wildfly.datasources.statistics-enabled:${wildfly.statistics-enabled:false}}">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE</connection-url>
<driver>h2</driver>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
</datasource>

...
</datasources>

密钥斗篷服务器配置:

<subsystem xmlns="urn:jboss:domain:keycloak-server:1.1">
<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>
</subsystem>

当我试图启动我的密钥斗篷服务器时,我得到了一个例外:

17:56:19,859 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) 
WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "KeycloakDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => ["jboss.jdbc-driver.postgresql"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing [jboss.jdbc- 
driver.postgresql]",
"org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.postgresql]"
]
}
17:56:19,860 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) 
WFLYCTL0013: Operation ("add") failed - address: ([
("subsystem" => "datasources"),
("data-source" => "KeycloakDS")
]) - failure description: {
"WFLYCTL0412: Required services that are not installed:" => [
"jboss.jdbc-driver.postgresql",
"jboss.jdbc-driver.postgresql"
],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.driver-demander.java:jboss/datasources/KeycloakDS is missing [jboss.jdbc- 
driver.postgresql]",
"org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.postgresql]",
"org.wildfly.data-source.KeycloakDS is missing [jboss.jdbc-driver.postgresql]"
]
}

看起来我以错误的方式配置了数据源,但我找不到错误。我检查了这个检查表,但它并不能解决我的问题。

请使用以下连接字符串重试:

jdbc:postgresql://192.168.99.100:5432/keycloak

而不是

jdbc:postgres://192.168.99.100:5432/keycloak

此外,考虑让SPI/connectionsJpa块处于默认值(我特别认为initializeEmpty应该为true(,我不记得我必须添加/修改这个块,所以请仔细检查。

您也可以禁用或注释ExampleDS-(h2(dataSource。

最新更新