title: How to integrate Keycloak 7 with Spring Boot 2
body: <p>I want to setup the Keycloak adapter (v7.0.0) for a Spring Boot 2.1.x backend. Somehow this doesn't work as expected and <code>mvn clean spring:boot-run</code> shows errors.</p>
  
  <p>To get a playground i cloned this working <a href="https://github.com/jinnerbichler/blog/tree/master/keycloak_4_spring_boot_2" rel="nofollow noreferrer">repo</a>. After a successful build with the old versions of Keycloak and Spring Boot i changed the dependencies (and versions).</p>
  
  <p>For the POM i included:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;dependency&gt;
    &lt;groupId&gt;org.keycloak&lt;/groupId&gt;
    &lt;artifactId&gt;keycloak-spring-boot-starter&lt;/artifactId&gt;
    &lt;version&gt;7.0.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;dependencyManagement&gt;
    &lt;dependencies&gt;
      &lt;dependency&gt;
        &lt;groupId&gt;org.keycloak.bom&lt;/groupId&gt;
          &lt;artifactId&gt;keycloak-adapter-bom&lt;/artifactId&gt;
          &lt;version&gt;7.0.0&lt;/version&gt;
          &lt;type&gt;pom&lt;/type&gt;
          &lt;scope&gt;import&lt;/scope&gt;
      &lt;/dependency&gt;
    &lt;/dependencies&gt;
  &lt;/dependencyManagement&gt;
  </code></pre>
  
  <p>and provide properties via the <code>application.yml</code> file:</p>
  
  <pre><code>keycloak:
    auth-server-url: http://127.0.0.1:8081/auth/
    resource: persons-app
    realm: PersonRealm
    public-client: true
    principal-attribute: preferred_username
  </code></pre>
  
  <p>This follows <a href="https://github.com/keycloak/keycloak-documentation/blob/master/securing_apps/topics/oidc/java/spring-boot-adapter.adoc" rel="nofollow noreferrer">Keycloaks docs</a>.</p>
  
  <p>The result is an error showing:</p>
  
  <pre class="lang-sh prettyprint-override"><code>Description:
  
  Parameter 1 of method setKeycloakSpringBootProperties in org.keycloak.adapters.springboot.KeycloakBaseSpringBootConfiguration required a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' that could not be found.
  
  
  Action:
  
  Consider defining a bean of type 'org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver' in your configuration.
  </code></pre>
  
  <p>This is already defined. So thats the problem. I don't know if there are certain restriction of what versions of Keycloak and Spring Boot work together. Maybe someone could explain what i missed here or what versions to set. Thanks!</p>