在使用keycloak Java Distribution 8.0.0 API和quarkus时,在创建Keycloak对象时遇到了问题。
依赖项列表
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.0.0.CR2</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.0.0.CR2</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
...
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
</dependencies>
主要方法
public static void main(String[] args) {
String serverUrl = "http://localhost:8181/auth";
String realmId = "master";
String clientId = "admin-cli";
KeycloakClient client = new KeycloakClient(serverUrl, realmId, clientId);
Keycloak kc = client.getKeycloak("adminuser", "adminpassword");
RealmResource realmResource = kc.realm("keycloak-client");
UsersResource userRessource = realmResource.users();
if (userRessource != null) {
System.out.println("Count: " + userRessource.count());
} else {
System.out.println("null");
}
}
keycloak客户端类
public Keycloak getKeycloak(final String username, final String password) {
// Type mismatch: cannot convert from Client to ResteasyClient
ResteasyClient resteasyClient = new ResteasyClientBuilder().connectionPoolSize(10)
.register(new CustomJacksonProvider()).build();
return KeycloakBuilder.builder().serverUrl(this.serverUrl).realm(this.realmId).username(username)
.password(password).clientId(this.clientId).resteasyClient(resteasyClient).build();
}
我知道这个问题是由keycloak-admin-client
引起的,该<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
仍将ResteasyClient用作类here,因此我将依存关系列表更改为以下内容。
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.resteasy.server.common.deployment.ResteasyServerCommonProcessor#build threw an exception: java.lang.IncompatibleClassChangeError: Implementing class
现在Main方法可以正常工作,但是又出现另一个错误。
FROM docker:dind
ADD crontab /etc/crontabs/root
CMD ["crond", "-f"]
我想知道这可能与当前版本一起使用quarkus和keycloak-admin。否则有任何解决方法。
谢谢