I'd like using spring-boot-starter-data-jpa features to create a non-web aplication. In the 52.4 documentation says:
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.
My AppPrincipalFrame looks like:
@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();
}
}
});
}
And boot application class looks like:
@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);
}
}
But does not work. Anybody have a sample about this?
Edited and exception added.
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
Regards.
@Component
and once in its ownrun()
method). Slightly bizarre, so maybe you didn't intend one of those? – Christianson