title: Read property values in the Java/ Spring
body: <p>I work with a Spring project and get the error stack provided,     </p>
  
  <pre><code>org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'riskEngineController': Unsatisfied dependency expressed through field 'ellaService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ellaService': Unsatisfied dependency expressed through field 'configHolder'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ellaFilterConfigHolder' defined in class path resource [com/xyz/iris/ella/config/EllaServiceConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.xyz.iris.ella.config.EllaFilterConfigHolder]: Factory method 'ellaFilterConfigHolder' threw exception; nested exception is java.lang.IllegalStateException: Required key 'ella.internal.buyer.filter' not found
  </code></pre>
  
  <p>The issue created when I tried to read a few properties from a configuration file named <code>settings.property</code>, </p>
  
  <pre><code>### ELLA
  ella.internal.buyer.filter=false
  ella.external.buyer.filter=false
  ella.shop.id.filter=123456,56789,545334
  ella.uri=localhost:${tomcat.port}/ella-web/api/v1/score
  </code></pre>
  
  <p>My service class is provided where I used the <code>@PostConstruct</code> to read the properties, </p>
  
  <pre><code>@Service
  @EnableAsync
  public class EllaService {
  
      @Autowired
      @Qualifier( ELLA_CONNECTOR_BEAN_NAME )
      private EntityServiceConnectable&lt;EllaResponseDto&gt; connector;
  
      @Autowired
      @Getter
      private EllaFilterConfigHolder configHolder;
  
      @Autowired
      @Getter
      private EllaConfiguration config;
  
      @Autowired
      private EllaServiceConfiguration ellaServiceConfiguration;
  
      @Autowired
      private Environment environment;
  
      @PostConstruct
      public void initialize() {
  
          this.configHolder = ellaServiceConfiguration.ellaFilterConfigHolder( environment );
      }
  
      /**
       * Asynchronously call Ella. Determine if traffic is applicable for Ella and if yes forward to Ella.
       *
       * @param irisBo
       */
      //    @Async( "ellaThreadPoolTaskExecutor" )
      @Async( ELLA_THREAD_POOL_TASK_EXECUTOR )
      public void invokeEllaAsync( final IrisBo irisBo ) {
  
          if( isTrafficAllowed( irisBo ) ) {
              callEllaService( irisBo );
          }
      }
  
      // some code 
  }
  </code></pre>
  
  <p>The <code>EllaServiceConfiguration</code> class is provided,  </p>
  
  <pre><code>@Configuration
  @Import( EllaConfiguration.class )
  public class EllaServiceConfiguration {
  
      private static final String SHOP_ID_STRING_SEPARATOR = ",";
  
      public static final String ELLA_SHOP_ID_FILTER_ENABLED_KEY = "ella.shop.id.filter";
  
      public static final String ELLA_INTERNAL_BUYER_FILTER_ENABLED_KEY = "ella.internal.buyer.filter";
      public static final String ELLA_EXTERNAL_BUYER_FILTER_ENABLED_KEY = "ella.external.buyer.filter";
  
      @Bean
      public EllaFilterConfigHolder ellaFilterConfigHolder( final Environment environment ) {
  
          final EllaFilterConfigHolder configHolder = new EllaFilterConfigHolder();
  
          configHolder.setInternalBuyerFilterEnabled( Boolean.getBoolean( environment
                                                                                  .getRequiredProperty( ELLA_INTERNAL_BUYER_FILTER_ENABLED_KEY ) ) );
          configHolder.setExternalBuyerFilterEnabled( Boolean.getBoolean( environment
                                                                                  .getRequiredProperty( ELLA_EXTERNAL_BUYER_FILTER_ENABLED_KEY ) ) );
  
          Set&lt;Integer&gt; set = new HashSet&lt;&gt;( getShopIdsToFilterAsList( environment ) );
          configHolder.getShopIdsToFilterSet().addAll( set );
  
          return configHolder;
      }
  
      private List&lt;Integer&gt; getShopIdsToFilterAsList( final Environment env ) {
  
          String shopIdListStr = env.getRequiredProperty( ELLA_SHOP_ID_FILTER_ENABLED_KEY );
          return Arrays.asList( shopIdListStr.split( SHOP_ID_STRING_SEPARATOR ) ).stream().map( Integer::parseInt )
                  .collect( Collectors.toList() );
      }
  
  }
  </code></pre>
  
  <p>The <code>EllaFilterConfigHolder</code> class, </p>
  
  <pre><code>@Getter
  @Setter
  @Component
  public class EllaFilterConfigHolder {
  
      private boolean isInternalBuyerFilterEnabled;
  
      private boolean isExternalBuyerFilterEnabled;
  
      @Setter( AccessLevel.NONE )
      private final Set&lt;Integer&gt; shopIdsToFilterSet = new HashSet&lt;&gt;();
  
  }
  </code></pre>
  
  <p>How do I read the properly read the field values for the <code>EllaFilterConfigHolder</code> class which I have tried in the  <code>EllaServiceConfiguration::ellaFilterConfigHolder</code> method?</p>