title: aws lambda and static initalizer block
body: <p>Am new to AWS lambda developing a lambda function using java.
  Am using spring in aws for DI(Dependency Injection) and i configured my lambda function with aws-api gateway. 
  while Initial Request i configured spring application context in static block because static block codes gets executed while loading the class in to main memory and the class will be loaded only once in a JVM. here is my code below:-</p>
  
  <pre><code>System.out.println(System.getenv(PROFIES_TYPE));
  springContainer = new  AnnotationConfigApplicationContext(BeanConfiguration.class);  
  springContainer.getEnvironment().addActiveProfile(System.getenv(PROFIES_TYPE));
  routingService = springContainer.getBean(RequestRoutingService.class);
  </code></pre>
  
  <p>this is my code which i written in static block where i can see the spring initilaizing logs twice in my aws cloud watch.
  Due to spring initialization twice first request  to my aws lambda function fails because of aws api gateway timeout....</p>