title: Spring Boot bootRun on Java 6
body: <p>I'm having trouble with the autoconfigurer for Jetty on Spring Boot 1.5.8. I need to use Jetty 8 instead of Jetty 9 for Java 6 compatibility, but the autoconfigurer does not detect the jetty classes:</p>
  
  <pre>
     EmbeddedServletContainerAutoConfiguration.EmbeddedJetty:
        Did not match:
           - @ConditionalOnClass did not find required class 'org.eclipse.jetty.webapp.WebAppContext' (OnClassCondition)
  </pre>
  
  <p>The dependencies part of my <code>build.gradle</code>:</p>
  
  <pre><code>dependencies {
      compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.12'
      compile 'org.springframework.boot:spring-boot-starter-web', {
          exclude module: 'spring-boot-starter-tomcat'
          exclude group: 'com.fasterxml.jackson.core'
      }
  
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.7.9' // last version for Java 6
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.7.9'
      compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.7.9.1'
  
      providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
      //providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
  
      providedRuntime 'org.springframework.boot:spring-boot-starter-jetty', {
          exclude group: 'org.eclipse.jetty'
          exclude group: 'org.eclipse.jetty.websocket'
      }
      def JETTY8_VERSION = '8.1.22.v20160922'
      ['jetty-server', 'jetty-webapp', 'jetty-servlets', 'jetty-continuation', 'jetty-client',
              'jetty-http', 'jetty-util', 'jetty-io', 'jetty-servlet', 'jetty-xml', 'jetty-security'].each {
          providedRuntime "org.eclipse.jetty:$it:$JETTY8_VERSION"
      }
  }
  </code></pre>
  
  <p>This subsequently results in:</p>
  
  <pre>
  org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)
      at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
      ...
  </pre>
  
  <p>The strange part is, if I declare <code>EmbeddedServletContainerFactoryBean</code> explicitly, it works:</p>
  
  <pre><code>@Bean
  EmbeddedServletContainerFactory jettyEmbeddedServletContainerFactory() {
      try {
          def clazz = Class.forName('org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory')
          clazz.newInstance()
      } catch (NoClassDefFoundError cnfe) {
          null
      }
  }
  </code></pre>