title: Spring Boot DevTools being used inside docker container even after exclusion in gradle build
body: <p>So we are using Spring boot to deliver our application. We use the Jib plugin to monitor create docker images and run them.
  We use gradle to build the project and there dev tools is identified as a <code>developmentOnly</code> dependency. 
  Just as mentioned in the spring docs at <a href="https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-devtools" rel="nofollow noreferrer">https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-devtools</a> .</p>
  
  <p>However when it runs in the container in prod  I still see it getting restarted now and then.
  My question is does the gradle configuration not really exlude it from packaging.
  Do i need to explicitly set the <code>-Dspring.devtools.restart.enabled=false</code> parameter ? </p>
  
  <p>Solution :</p>
  
  <p>So turns out it was the gradle jib plugin playing games.
  While the spring documentation is spot on about how to go about removing the dependency from gradle spring boot project. The technique of specifying a <code>developmentOnly</code> only helps in telling gradle to ignore the dev tools. The jib gradle plugin has a mind of its own.</p>
  
  <p>It includes all jars when building a docker image and there is no way to exclude any jar. The only reasonable way is to customize the gradle jib plugin in build.gradle to write this ,</p>
  
  <pre><code> jib {
      from {
          image 'gcr.io/distroless/java:11'
      }
      container {
          jvmFlags = ['-Xms1G', '-Xmx1G', '-Dspring.devtools.restart.enabled = false']
      }
  }
  </code></pre>
  
  <p>This will make sure that even if the jar is included the container environment has the restart taken care of.</p>
  
  <p>Reference : <a href="https://github.com/spring-projects/spring-boot/issues/15382" rel="nofollow noreferrer">https://github.com/spring-projects/spring-boot/issues/15382</a></p>