public class Micronaut extends DefaultApplicationContextBuilder implements ApplicationContextBuilder
Main entry point for running a Micronaut application.
Modifier | Constructor and Description |
---|---|
protected |
Micronaut()
The default constructor.
|
Modifier and Type | Method and Description |
---|---|
Micronaut |
args(String... args)
Set the command line arguments.
|
static Micronaut |
build(String... args)
Run the application for the given arguments.
|
Micronaut |
classes(Class... classes)
Add classes to be included in the initialization of the application.
|
Micronaut |
classLoader(ClassLoader classLoader)
The class loader to be used.
|
Micronaut |
environments(String... environments)
The environments to use.
|
Micronaut |
exclude(String... configurations)
Allow customizing the configurations that will be loaded.
|
protected void |
handleStartupException(Environment environment,
Throwable exception)
Default handling of startup exceptions.
|
Micronaut |
include(String... configurations)
Allow customizing the configurations that will be loaded.
|
Micronaut |
mainClass(Class mainClass)
The main class used by this application.
|
<T extends Throwable> |
mapError(Class<T> exception,
Function<T,Integer> mapper)
Maps an exception to the given error code.
|
Micronaut |
packages(String... packages)
The packages to include for package scanning.
|
Micronaut |
properties(Map<String,Object> properties)
Properties to override from the environment.
|
Micronaut |
propertySources(PropertySource... propertySources)
Additional property sources.
|
static ApplicationContext |
run(Class[] classes,
String... args)
Run the application for the given arguments.
|
static ApplicationContext |
run(Class cls,
String... args)
Run the application for the given arguments.
|
static ApplicationContext |
run(String... args)
Run the application for the given arguments.
|
Micronaut |
singletons(Object... beans)
Additional singletons to register prior to startup.
|
ApplicationContext |
start()
Starts the
ApplicationContext . |
build
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
build, run
public ApplicationContext start()
ApplicationContextBuilder
ApplicationContext
.start
in interface ApplicationContextBuilder
Micronaut
public Micronaut include(@Nullable String... configurations)
DefaultApplicationContextBuilder
include
in interface ApplicationContextBuilder
include
in class DefaultApplicationContextBuilder
configurations
- The configurations to includepublic Micronaut exclude(@Nullable String... configurations)
DefaultApplicationContextBuilder
exclude
in interface ApplicationContextBuilder
exclude
in class DefaultApplicationContextBuilder
configurations
- The configurations to excludepublic Micronaut classes(@Nullable Class... classes)
classes
- The applicationpublic Micronaut properties(@Nullable Map<String,Object> properties)
ApplicationContextBuilder
properties
in interface ApplicationContextBuilder
properties
in class DefaultApplicationContextBuilder
properties
- The propertiespublic Micronaut singletons(Object... beans)
ApplicationContextBuilder
singletons
in interface ApplicationContextBuilder
singletons
in class DefaultApplicationContextBuilder
beans
- The beanspublic Micronaut propertySources(@Nullable PropertySource... propertySources)
ApplicationContextBuilder
propertySources
in interface ApplicationContextBuilder
propertySources
in class DefaultApplicationContextBuilder
propertySources
- The property sources to includepublic Micronaut mainClass(Class mainClass)
ApplicationContextBuilder
mainClass
in interface ApplicationContextBuilder
mainClass
in class DefaultApplicationContextBuilder
mainClass
- The main classpublic Micronaut classLoader(ClassLoader classLoader)
ApplicationContextBuilder
classLoader
in interface ApplicationContextBuilder
classLoader
in class DefaultApplicationContextBuilder
classLoader
- The classloaderpublic Micronaut args(@Nullable String... args)
args
- The argumentspublic Micronaut environments(@Nullable String... environments)
ApplicationContextBuilder
environments
in interface ApplicationContextBuilder
environments
in class DefaultApplicationContextBuilder
environments
- The environmentspublic Micronaut packages(@Nullable String... packages)
ApplicationContextBuilder
packages
in interface ApplicationContextBuilder
packages
in class DefaultApplicationContextBuilder
packages
- The packagespublic <T extends Throwable> Micronaut mapError(Class<T> exception, Function<T,Integer> mapper)
T
- The exception typeexception
- The exceptionmapper
- The mapperpublic static Micronaut build(String... args)
args
- The argumentsApplicationContext
public static ApplicationContext run(String... args)
args
- The argumentsApplicationContext
public static ApplicationContext run(Class cls, String... args)
cls
- The application classargs
- The argumentsApplicationContext
public static ApplicationContext run(Class[] classes, String... args)
classes
- The application classesargs
- The argumentsApplicationContext
protected void handleStartupException(Environment environment, Throwable exception)
environment
- The environmentexception
- The exceptionApplicationStartupException
- If the server cannot be shutdown with an appropriate exist code