title: Guice default value for @Named
body: <p>I am reading the properties from a conf file using Guice</p>
  
  <pre><code>@Inject
  @Named("test.var1")
  private int var1 = 2;
  </code></pre>
  
  <p>Here, the value of test.var1 in the conf file is being injected to var1 successfully. If this property in missing in the file, i want it to be set to 2 by default. But, when this property "test.var1" is missing in the property file, i am getting a compilation error. </p>
  
  <pre><code>Explicit bindings are required and java.lang.Integer annotated with @com.google.inject.name.Named(value=test.var1) is not explicitly bound.
    while locating java.lang.Integer annotated with @com.google.inject.name.Named(value=test.var1)
      for parameter 6 at test1.TestParser.&lt;init&gt;(TestParser.java:62)
    at test1.CarbonServerModule.configure(CarbonServerModule.java:41)
  
  1 error
      at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
      at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
      at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
      at com.google.inject.Guice.createInjector(Guice.java:95)
      at com.google.inject.Guice.createInjector(Guice.java:72)
      at test1.Main.&lt;init&gt;(Main.java:198)
      at test1.Main.main(Main.java:244)
  </code></pre>
  
  <p>Can someone plz help me with what i am trying to do here?</p>