title: Do annotations on a class still get called when only accessing static members?
body: <p>I have the following class:</p>
  
  <pre><code>package hello;
  
  import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
  import org.springframework.boot.SpringApplication;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.stereotype.Component;
  
  @Component
  @EnableAutoConfiguration
  public class Application {
  
      public static void main(String[] args) {  
          SpringApplication.run(Application.class, args);
      }
  }
  </code></pre>
  
  <p>If I reference it in my main camel route, like so:</p>
  
  <pre><code>package com.example.integration;
  
  import hello.*;
  
  import org.apache.camel.ProducerTemplate;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.support.ClassPathXmlApplicationContext;
  
  
  public class TestCamelSpring {
  
          public static void main(String[] args) {
                  ApplicationContext context = new ClassPathXmlApplicationContext("camelspring.xml");
              ProducerTemplate camelTemplate = context.getBean("camelTemplate", ProducerTemplate.class);
  
          Application.main(args);
          System.out.println("Message Sending started");
          camelTemplate.sendBody("jms:queue:testQSource","Sample Message");
          System.out.println("Message sent");
  
      }
  
  }
  </code></pre>
  
  <p>Do my annotations in Application.class still get accessed even though I only reference Application.main?</p>
  
  <p>I ask because the @EnableAutoConfiguration is supposed to configure the application for Tomcat, but now that I am not running Application.class directly, the application is defaulting to jetty and then I get an error that WebSockets are only supported in Tomcat.</p>
  
  <p>Has anyone had this issue before or know how to solve it?</p>
  
  <p>Here is the stack trace. I can see from the console log that it never starts the Tomcat instance that it does when the whole class is accessed in the example. It seems to be continuing as if it is a jetty app rather than Tomcat. Please correct me if any of these assumptions are wrong:</p>
  
  <pre><code>Caused by: java.lang.IllegalStateException: Websockets are currently only supported in Tomcat (found class org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory). 
  at org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration$1.customize(WebSocketAutoConfiguration.java:74)
  at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:67)
  at org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor.postProcessBeforeInitialization(EmbeddedServletContainerCustomizerBeanPostProcessor.java:54)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:407)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1545)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
  ... 16 more
  </code></pre>