title: How to configure spring-boot with swing application
body: <p>I'd like using spring-boot-starter-data-jpa features to create a non-web aplication.
  In the 52.4 documentation says:</p>
  
  <blockquote>
    <p>Application code that you want to run as your business logic can be
    implemented as a CommandLineRunner and dropped into the context as a
    @Bean definition.</p>
  </blockquote>
  
  <p>My <strong>AppPrincipalFrame</strong> looks like:</p>
  
  <pre><code>@Component
  public class AppPrincipalFrame extends JFrame implements CommandLineRunner{
  
  private JPanel contentPane;
  
  @Override
  public void run(String... arg0) throws Exception {
      EventQueue.invokeLater(new Runnable() {
          public void run() {
              try {
                  AppPrincipalFrame frame = new AppPrincipalFrame();
                  frame.setVisible(true);
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
      });
  }
  </code></pre>
  
  <p>And <strong>boot application class</strong> looks like:</p>
  
  <pre><code>@Configuration
  @ComponentScan
  @EnableAutoConfiguration
  public class Application {  
    public static void main(String[] args) {
     ApplicationContext context = SpringApplication.run(Application.class, args);
     AppPrincipalFrame appFrame = context.getBean(AppPrincipalFrame.class);
    }
  }
  </code></pre>
  
  <p>But does not work. Anybody have a sample about this?</p>
  
  <p>Edited and exception added.</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException:      Error creating bean with name 'appPrincipalFrame'.
  
  Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [es.adama.swing.ui.AppPrincipalFrame]: Constructor threw exception; nested exception is java.awt.HeadlessException 
  </code></pre>
  
  <p>Regards.</p>