Bean definitions public static void main(String[] args) throws Exception { SpringApplication.run(MyApplication.class, args); }
For more advanced configuration a {@link SpringApplication} instance can be created andcustomized before being run:
public static void main(String[] args) throws Exception { SpringApplication app = new SpringApplication(MyApplication.class); // ... customize app settings here app.run(args) }
{@link SpringApplication}s can read beans from a variety of different sources. It is generally recommended that a single {@code @Configuration} class is used to bootstrapyour application, however, any of the following sources can also be used:
- {@link Class} - A Java class to be loaded by {@link AnnotatedBeanDefinitionReader}
- {@link Resource} - An XML resource to be loaded by {@link XmlBeanDefinitionReader}, or a groovy script to be loaded by {@link GroovyBeanDefinitionReader}
- {@link Package} - A Java package to be scanned by{@link ClassPathBeanDefinitionScanner}
- {@link CharSequence} - A class name, resource handle or package name to loaded asappropriate. If the {@link CharSequence} cannot be resolved to class and does notresolve to a {@link Resource} that exists it will be considered a {@link Package}.
@author Phillip Webb
@author Dave Syer
@author Andy Wilkinson
@author Christian Dupuis
@see #run(Object,String[])
@see #run(Object[],String[])
@see #SpringApplication(Object)