title: Spring Boot + Elastic Beanstalk .ebextensions in JAR
body: <p>I have a very standard Spring Boot application (with a <code>application.properties</code> properties file located in standard <code>/src/main/resources</code> folder) which I'm deploying on AWS Elastic Beanstalk as a "fat JAR".  It works quite nicely but there is an issue with image uploading on the server.  After some investigation it seems that the NGINX configuration needs to be tweaked (increase <code>client_max_body_size</code> to something so it can accept uploads up to <code>10MB</code>) and therefore I have added an <code>.ebextensions</code> folder under <code>/src/main/resources</code> with a file with the following content (taken from <a href="https://stackoverflow.com/questions/18908426/increasing-client-max-body-size-in-nginx-conf-on-aws-elastic-beanstalk">this answer</a>): -</p>
  
  <pre><code>files:
      "/etc/nginx/conf.d/proxy.conf":
          mode: "000755"
          owner: root
          group: root
          content: |
             client_max_body_size 20M;
  </code></pre>
  
  <p>However, when I run <code>mvn</code> on my build it doesn't create <code>.ebextensions</code> in the root folder and I'm wondering what is the best solution for this.  My <code>pom.xml</code> file is pretty minimal and currently contains the following: </p>
  
  <pre><code>    ...
  
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      ....
  
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
  
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.springframework&lt;/groupId&gt;
                      &lt;artifactId&gt;springloaded&lt;/artifactId&gt;
                      &lt;version&gt;1.2.6.RELEASE&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
  
          &lt;/plugin&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <h2>Update 1</h2>
  
  <p>@Lorena when I insert <code>&lt;resources&gt; ...</code> XML into my <code>pom.xml</code> and then start the server it crashes out with the following: -</p>
  
  <pre><code>2017-03-20 21:40:29.504  WARN 10784 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'emailApiSpringBootMail': Unsatisfied dependency expressed through field 'javaMailSender'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.mail.javamail.JavaMailSender' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
  2017-03-20 21:40:29.507  INFO 10784 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
  2017-03-20 21:40:29.533  WARN 10784 --- [           main] o.s.boot.SpringApplication               : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
  2017-03-20 21:40:29.637 ERROR 10784 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
  
  ***************************
  APPLICATION FAILED TO START
  ***************************
  
  Description:
  
  Field javaMailSender in com.myapp.server.api.impl.EmailApiSpringBootMail required a bean of type 'org.springframework.mail.javamail.JavaMailSender' that could not be found.
      - Bean method 'mailSender' not loaded because AnyNestedCondition 0 matched 2 did not; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.JndiNameProperty @ConditionalOnProperty (spring.mail.jndi-name) did not find property 'jndi-name'; NestedCondition on MailSenderAutoConfiguration.MailSenderCondition.HostProperty @ConditionalOnProperty (spring.mail.host) did not find property 'host'
  </code></pre>
  
  <p>Removing the XML again fixes the issue so unfortunately this won't work.</p>
  
  <hr>
  
  <h2>Update 2</h2>
  
  <p>The issues described in the previous section seemed to be that the new <code>&lt;resources&gt;</code> pointing to the <code>.ebextentions</code> was overridding  the <code>&lt;resources&gt;</code> block defined in: -</p>
  
  <pre><code>&lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;1.4.3.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  </code></pre>
  
  <p>To get everything working I copied it across and appended to the end as follows: -</p>
  
  <pre><code>    &lt;resources&gt;
  
          &lt;resource&gt;
              &lt;directory&gt;src/main/resources/ebextensions&lt;/directory&gt;
              &lt;targetPath&gt;.ebextensions&lt;/targetPath&gt;
              &lt;filtering&gt;true&lt;/filtering&gt;
          &lt;/resource&gt;
  
          &lt;!-- Followed is copied from `spring-boot-starter-parent.pom` --&gt;
  
          &lt;resource&gt;
              &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
              &lt;filtering&gt;true&lt;/filtering&gt;
              &lt;includes&gt;
                  &lt;include&gt;**/application*.yml&lt;/include&gt;
                  &lt;include&gt;**/application*.properties&lt;/include&gt;
              &lt;/includes&gt;
          &lt;/resource&gt;
          &lt;resource&gt;
              &lt;directory&gt;${basedir}/src/main/resources&lt;/directory&gt;
              &lt;excludes&gt;
                  &lt;exclude&gt;**/application*.yml&lt;/exclude&gt;
                  &lt;exclude&gt;**/application*.properties&lt;/exclude&gt;
              &lt;/excludes&gt;
          &lt;/resource&gt;
  
      &lt;/resources&gt;
  </code></pre>
  
  <p>Thanks everyone for your help!</p>