1.执行命令编译源码
mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install
执行完成,项目打包在项目目录\distribution\server-dist\target下
2.下载postgresql的驱动,下载路径如下
https://jdbc.postgresql.org/download.html
- modules\system\layers\keycloak\org 目录下创建 postgresql\main文件夹
- 导入驱动包
- 在此目录下新建module.xml 文件
<?xml version="1.0" encoding="UTF-8"?> <module xmlns="urn:jboss:module:1.3" name="org.postgresql"> <resources> <resource-root path="postgresql-42.3.3.jar"/> </resources> <dependencies> <module name="javax.api"/> <module name="javax.transaction.api"/> </dependencies> </module>
3.修改目录/standalone/configurationstandalone.xml配置
- 修改数据驱动
<drivers> <driver name="postgresql" module="org.postgresql"> <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class> </driver> </drivers>
-
drivers上面有两个datasource标签,都注释掉
- 添加配置自己的datasource数据源
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS" enabled="true" use-java-context="true" > <connection-url>jdbc:postgresql://127.0.0.1:5432/keycloak</connection-url> <driver>postgresql</driver> <security> <user-name>postgres</user-name> <password>postgres</password> </security> </datasource>
- 搜索default-bindings 注释掉此标签
- 还可以配置其他ip访问
- windos双击standalone.bat启动 ok
- linux启动
操作权限 chmod +x standalone.sh 执行standalone.sh 后台启动 nohup ./standalone.sh &