KeyCloak14.0 源码编译(二次开发)

1.基础准备(building.md official)

环境: windows10 jdk.18 maven 3.6 git 2.6

Building from source

Ensure you have JDK 8 (or newer), Maven 3.5.4 (or newer) and Git installed

java -version
mvn -version
git --version

First clone the Keycloak repository:

git clone -b 14.0.0 https://github.com/keycloak/keycloak.git
cd keycloak

To build Keycloak run:

mvn clean install

This will build all modules and run the testsuite.

To build the ZIP distribution run:

mvn clean install -Pdistribution

Once completed you will find distribution archives in distribution.

To build only the server run:

mvn -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install

Skip Tests

mvn clean install -Pdistribution -DskipTests

​
**NOTE**
​
Classes from `org.keycloak.testsuite.*` packages aren't suitable to be used in production.
## Starting Keycloak
To start Keycloak during development first build as specified above, then run:
    mvn -f testsuite/utils/pom.xml exec:java -Pkeycloak-server 
When running testsuite, by default an account with username `admin` and password `admin` will be created within the master realm at start.
To start Keycloak from the server distribution first build the distribution it as specified above, then run:
    tar xfz distribution/server-dist/target/keycloak-<VERSION>.tar.gz
    cd keycloak-<VERSION>
    bin/standalone.sh
To stop the server press `Ctrl + C`.

2.启动入口

下载代码在项目目录下面找到 testsuite/utils/src/resources/META-INF/keycloak-server.json文件。Testsuite/utils 是keycloak提供的启动项目,后面的项目启动也在这个项目中。

现在我们来启动代码,进入testsuite/utils 项目下,在源码下找到 KeycloakServer 类,打开这个类找到main方法,这个就是启动的入口。 此处参考:https://blog.youkuaiyun.com/jkin_wan/article/details/109643361

3.错误处理

3.1编译错误

当出现错误“java: Compilation failed: internal java compiler error”时,将jdk版本统一到1.8,特别是java compiler(idea的设置)中module每一项都调至1.8,即可避免这些错误。

详细说明 :在Idea中编译时出现错误:java: Compilation failed: internal java compiler error 解决办法很简单:File-->Setting...-->Build,Execution,Deployment-->Compiler-->Java Compiler 设置相应Module的target bytecode version的合适版本(跟你jdk版本一致)

3.2安装错误

当mvn install 时出现[ERROR] Failed to execute goal com.igormaznitsa:mvn-golang-wrapper:2.3.4

在Linux下显示的详细信息,原因是因为XXX(优快云审核需要)的原因。

`[ERROR] Failed to execute goal com.igormaznitsa:mvn-golang-wrapper:2.3.4:get (get-mousetrap) on project integration-arquillian-tests-base: Connect to storage.googleapis.com:443 [storage.googleapis.com/172.217.161.176, storage.googleapis.com/172.217.163.240, storage.googleapis.com/172.217.174.208, storage.googleapis.com/216.58.200.80, storage.googleapis.com/216.58.220.208, storage.googleapis.com/142.250.66.48, storage.googleapis.com/142.250.66.80, storage.googleapis.com/142.250.66.112, storage.googleapis.com/142.250.199.80, storage.googleapis.com/142.250.204.48, storage.googleapis.com/142.250.204.80, storage.googleapis.com/142.250.204.144, storage.googleapis.com/142.250.207.80, storage.googleapis.com/172.217.26.144, storage.googleapis.com/172.217.161.144] failed: 拒绝连接 (Connection refused) -> [Help 1]`    

答:windows上全局代理proxifier设定 具体设置为:mvn.exe;mvn.cmd;curl.exe;wget.exe; target host 设置为storage.googleapis.com;*.google.com; 可以解决此错误(走http通道,非socks5通道)

4.最终输出

最终输出二进制包在

`keycloak\distribution\server-dist\target`

评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值