title: Why Spring Boot ignores @Named annotation when deploying a WAR?
body: <p>I have to deploy a Spring Boot application in a Tomcat 8 as a WAR.</p>
  
  <p>Everything works when launching the application via the embedded Tomcat but when I deploy to a standalone Tomcat, components are wired only if annotated with <code>@Component</code> annotation (or one of its derivatives, like <code>@Service</code> or <code>@Controller</code>). If I use the JSR-330 <code>@Named</code> annotation, beans are not found and the container cannot start the application because it cannot find any bean that qualifies for the wiring:</p>
  
  <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [TestService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
  </code></pre>
  
  <p>Not all JSR-330 annotations are ignored, as <code>@Inject</code> works.</p>
  
  <p><strong>Is there a way to configure Spring Boot to honor JSR-330 annotations when running in a standalone (not embedded) container like Tomcat?</strong></p>
  
  <p>Relevant code sections:
  pom.xml</p>
  
  <pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;group&lt;/groupId&gt;
      &lt;artifactId&gt;art&lt;/artifactId&gt;
      &lt;version&gt;1.0.0-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
  
      &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.3.0.RELEASE&lt;/version&gt;
      &lt;/parent&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p>ContextConfiguration (in the root package):</p>
  
  <pre><code>import javax.inject.Inject;
  
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.context.properties.EnableConfigurationProperties;
  import org.springframework.boot.context.web.SpringBootServletInitializer;
  import org.springframework.cache.CacheManager;
  import org.springframework.cache.annotation.EnableCaching;
  import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
  import org.springframework.context.annotation.Bean;
  
  import lombok.extern.slf4j.Slf4j;
  
  @SpringBootApplication
  @Slf4j
  public class ContextConfiguration extends SpringBootServletInitializer{
  
  }
  </code></pre>
  
  <p>TestService (in the root package)</p>
  
  <pre><code>@Named
  public class TestService {
  }
  </code></pre>
  
  <p>TestRestController (in the root package)</p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RestController;
  
  @RestController
  @RequestMapping("/test")
  public class TestRestController {
      @Autowired
      public TestRestController (TestService testService) {
          super(testService);
      }
  }
  </code></pre>