我正在将keycloak 6.0.1与springboot版本1.5.4集成在一起,但是出现如下所示的应用程序部署错误-
2019-07-01 16:36:19.613 INFO 4920 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'securityProperties' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration; factoryMethodName=securityProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/security/SecurityAutoConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.security.SecurityFilterAutoConfiguration; factoryMethodName=securityProperties; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/security/SecurityFilterAutoConfiguration.class]]
2019-07-01 16:36:19.789 ERROR 4920 --- [ main] o.s.boot.SpringApplication : Application startup failed
java.lang.NoClassDefFoundError: org/springframework/boot/web/embedded/undertow/UndertowDeploymentInfoCustomizer
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_181]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_181]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_181]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613) ~[spring-core-4.3.9.RELEASE.jar:4.3.9.RELEASE]
有人可以帮助我解决此问题吗?
我尝试下载某些博客建议的keycloak 3.3.0.final版本,并与提到的springboot版本一起使用,但是我可以获取keycloak 3.3.0版本的下载链接。
答案 0 :(得分:1)
如果您使用keycloak-spring-boot-starter
与keycloak集成,则需要使用支持spring-boot 4.0.0.Final
1.5.2.RELEASE
。
您可以检查依赖项here
使用密钥斗篷6.0.1
支持spring-boot 2.0.3.RELEASE
答案 1 :(得分:0)
最近2周我在Keycloak玩耍。
我使Keycloak 6.0.1与Spring Boot 1.4.1一起使用。刚刚尝试过Spring Boot 1.5.2版,看起来可以正常工作。
我根据该回购做了例子 https://github.com/thomasdarimont/spring-boot-admin-keycloak-example
删除了spring-boot-starter-actuator依赖性,因为它并不在意。
我得到的todo-service pom.xml是:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>todo-service</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>todo-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<java.version>1.8</java.version>
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
<lombok.version>1.16.10</lombok.version>
<keycloak.version>6.0.1</keycloak.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.keycloak.bom</groupId>
<artifactId>keycloak-adapter-bom</artifactId>
<version>${keycloak.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
试用该仓库,将应用程序属性更新为您的密钥斗篷设置,使其正常运行,并将必要的依赖项复制到原始项目中,直到获得所需的东西(我为我所做的)
结论:Keycloak 6.0.1可以与Spring Boot 1.x一起使用