title: Spring Boot fails to start - ConfigurationProperties throws UnboundConfigurationPropertiesException
body: <p>I migrated an app from spring-boot 1.5.9 to 2.2.4, and now I have the following issue:</p>
  
  <pre><code>***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Binding to target [Bindable@1f5150ed type = com.domain.config.RolesConfig, value = 'provided', annotations = array&lt;Annotation&gt;[@org.springframework.boot.context.properties.ConfigurationProperties(ignoreInvalidFields=false, ignoreUnknownFields=false, prefix=role, value=role)]] failed:
  
      Property: role.rolebuctravelwatchers
      Value: Admin
      Origin: "role.roleBucTravelWatchers" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolecommandcenter
      Value: Admin
      Origin: "role.roleCommandCenter" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.roleemployee
      Value: Student
      Origin: "role.roleEmployee" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolefacility
      Value: Admin
      Origin: "role.roleFacility" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolegm
      Value: Admin
      Origin: "role.roleGM" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolehr
      Value: Admin
      Origin: "role.roleHR" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolehrwatchers
      Value: Admin
      Origin: "role.roleHRWatchers" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolemanager
      Value: Admin
      Origin: "role.roleManager" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.roleofficead
      Value: Admin
      Origin: "role.roleOfficeAD" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      Property: role.rolewatcherpm
      Value: Admin
      Origin: "role.roleWatcherPM" from property source "class path resource [application-dev.properties]"
      Reason: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
  
  Action:
  
  Update your application's configuration
  
  21:27:24,446 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 76) MSC000001: Failed to start service jboss.deployment.unit."App-0.0.1-SNAPSHOT.war".undertow-deployment: org.jboss.msc.service.StartException in service jboss.deployment.unit."App-0.0.1-SNAPSHOT.war".undertow-deployment: java.lang.RuntimeException: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
      at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
      at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
      at java.lang.Thread.run(Thread.java:748)
      at org.jboss.threads.JBossThread.run(JBossThread.java:485)
  Caused by: java.lang.RuntimeException: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:252)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:96)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78)
      ... 8 more
  Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:110)
      at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:96)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:879)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
      at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:152)
      at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:132)
      at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:92)
      at com.domain.Application.onStartup(Application.java:34)
      at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
      at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:203)
      at io.undertow.servlet.core.DeploymentManagerImpl$1.call(DeploymentManagerImpl.java:185)
      at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42)
      at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
      at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
      at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
      at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:250)
      ... 10 more
  Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:364)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:324)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:308)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:238)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225)
      at org.springframework.boot.context.properties.ConfigurationPropertiesBinder.bind(ConfigurationPropertiesBinder.java:89)
      at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.bind(ConfigurationPropertiesBindingPostProcessor.java:107)
      ... 42 more
  Caused by: org.springframework.boot.context.properties.bind.UnboundConfigurationPropertiesException: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound.
      at org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler.checkNoUnboundElements(NoUnboundElementsBindHandler.java:83)
      at org.springframework.boot.context.properties.bind.handler.NoUnboundElementsBindHandler.onFinish(NoUnboundElementsBindHandler.java:71)
      at org.springframework.boot.context.properties.bind.Binder.handleBindResult(Binder.java:340)
      at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:321)
      ... 47 more
  
  21:27:24,485 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" =&gt; "App-0.0.1-SNAPSHOT.war")]) - failure description: {"WFLYCTL0080: Failed services" =&gt; {"jboss.deployment.unit.\"App-0.0.1-SNAPSHOT.war\".undertow-deployment" =&gt; "java.lang.RuntimeException: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      Caused by: java.lang.RuntimeException: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'rolesConfig': Could not bind properties to 'RolesConfig' : prefix=role, ignoreInvalidFields=false, ignoreUnknownFields=false; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'role' to com.domain.config.RolesConfig
      Caused by: org.springframework.boot.context.properties.bind.UnboundConfigurationPropertiesException: The elements [role.rolebuctravelwatchers,role.rolecommandcenter,role.roleemployee,role.rolefacility,role.rolegm,role.rolehr,role.rolehrwatchers,role.rolemanager,role.roleofficead,role.rolewatcherpm] were left unbound."}}
  </code></pre>
  
  <p>I have my application-dev.properties file:</p>
  
  <pre><code>#application users roles
  role.roleGM=Admin
  role.roleOfficeAD=Admin
  role.roleFacility=Admin
  role.roleManager=Admin
  role.roleHR=Admin
  role.roleHRWatchers=Admin
  role.roleWatcherPM=Admin
  role.roleEmployee=Student
  
  role.roleCommandCenter=Admin
  role.roleBucTravelWatchers=Admin
  </code></pre>
  
  <p>And my RolesConfig java Class:</p>
  
  <pre><code>package com.domain.config;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  import java.util.stream.Collectors;
  
  import org.springframework.boot.context.properties.ConfigurationProperties;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.PropertySource;
  import org.springframework.security.core.context.SecurityContextHolder;
  
  @Configuration
  @PropertySource("classpath:${spring.profiles.active}.properties")
  @ConfigurationProperties(prefix = "role", ignoreUnknownFields = false)
  public class RolesConfig {
  
      private final static String rolePrefix = "ROLE_";
  
      public static String roleGM;
      public static String roleOfficeAD;
      public static String roleFacility;
      public static String roleManager;
      public static String roleHR;
      public static String roleHRWatchers;
      public static String roleWatcherPM;
      public static String roleExternalWatcher;
      public static String roleEmployee;
      public static String roleCommandCenter;
      public static String roleBucTravelWatchers;
  
      public Set&lt;String&gt; getAllRoles() {
          return Arrays.asList(this.getClass().getDeclaredFields()).stream().map(field -&gt; {
              try {
                  return field.get(new String());
              } catch (IllegalArgumentException | IllegalAccessException e) {
                  return null;
              }
          }).filter(p -&gt; {
              return p != null &amp;&amp; !p.equals("ROLE_");
          }).map(p -&gt; {
              return p.toString();
          }).collect(Collectors.toCollection(HashSet&lt;String&gt;::new));
      }
  
      private static String getFormatedRole(String role) {
          return rolePrefix + role.toUpperCase();
      }
  
      public boolean isUserInRoles(String... arg) {
          List&lt;String&gt; roles = new ArrayList&lt;String&gt;(Arrays.asList(arg));
          return SecurityContextHolder.getContext()
                                      .getAuthentication()
                                      .getAuthorities()
                                      .stream()
                                      .map(p -&gt; {
                                          return p.toString();
                                      }).anyMatch(p -&gt; roles.contains(p));
      }
  
      public static String getRoleGM() {
          return roleGM;
      }
  
      public static void setRoleGM(String roleGM) {
          RolesConfig.roleGM = getFormatedRole(roleGM);
      }
  
      public static String getRoleOfficeAD() {
          return roleOfficeAD;
      }
  
      public static void setRoleOfficeAD(String roleOfficeAD) {
          RolesConfig.roleOfficeAD = getFormatedRole(roleOfficeAD);
      }
  
      public static String getRoleFacility() {
          return roleFacility;
      }
  
      public static void setRoleFacility(String roleFacility) {
          RolesConfig.roleFacility = getFormatedRole(roleFacility);
      }
  
      public static String getRoleManager() {
          return roleManager;
      }
  
      public static void setRoleManager(String roleManager) {
          RolesConfig.roleManager = getFormatedRole(roleManager);
      }
  
      public static String getRoleHR() {
          return roleHR;
      }
  
      public static void setRoleHR(String roleHR) {
          RolesConfig.roleHR = getFormatedRole(roleHR);
      }
  
      public static String getRoleHRWatchers() {
          return roleHRWatchers;
      }
  
      public static void setRoleHRWatchers(String roleHRWatchers) {
          RolesConfig.roleHRWatchers = getFormatedRole(roleHRWatchers);
      }
  
      public static String getRoleWatcherPM() {
          return roleWatcherPM;
      }
  
      public static void setRoleWatcherPM(String roleWatcherPM) {
          RolesConfig.roleWatcherPM = getFormatedRole(roleWatcherPM);
      }
  
      public static String getRoleExternalWatcher() {
          return roleExternalWatcher;
      }
  
      public static void setRoleExternalWatcher(String roleExternalWatcher) {
          RolesConfig.roleExternalWatcher = getFormatedRole(roleExternalWatcher);
      }
  
      public static String getRoleEmployee() {
          return roleEmployee;
      }
  
      public static void setRoleEmployee(String roleEmployee) {
          RolesConfig.roleEmployee = getFormatedRole(roleEmployee);
      }
  
      public static String getRoleCommandCenter() {
          return roleCommandCenter;
      }
  
      public static void setRoleCommandCenter(String roleCommandCenter) {
          RolesConfig.roleCommandCenter = getFormatedRole(roleCommandCenter);
      }
  
      public static String getRoleBucTravelWatchers() {
          return roleBucTravelWatchers;
      }
  
      public static void setRoleBucTravelWatchers(String roleBucTravelWatchers) {
          RolesConfig.roleBucTravelWatchers = getFormatedRole(roleBucTravelWatchers);
      }
  
  }
  
  </code></pre>
  
  <p>Removing @Configuration will cause other bugs across the app, as I've saw some people suggest this.
  Also, removing ignoreUnknownFields makes the app complete the build, but the values in the fields are null.</p>
  
  <p>I don't understand why this doesn't work anymore. Every resource I could possibly find does the same thing. This worked before with no problems. Can anyone point me towards what I'm doing wrong, please? </p>