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(java.lang.String... args)
Set the command line arguments.
|
static Micronaut |
build(java.lang.String... args)
Run the application for the given arguments.
|
Micronaut |
classes(java.lang.Class... classes)
Add classes to be included in the initialization of the application.
|
Micronaut |
classLoader(java.lang.ClassLoader classLoader)
The class loader to be used.
|
Micronaut |
environmentPropertySource(boolean environmentPropertySource)
Set whether environment variables should contribute to configuration.
|
Micronaut |
environments(java.lang.String... environments)
The environments to use.
|
Micronaut |
environmentVariableExcludes(java.lang.String... environmentVariables)
Which environment variables should not contribute to configuration.
|
Micronaut |
environmentVariableIncludes(java.lang.String... environmentVariables)
Which environment variables should contribute to configuration.
|
Micronaut |
exclude(java.lang.String... configurations)
Allow customizing the configurations that will be loaded.
|
protected void |
handleStartupException(Environment environment,
java.lang.Throwable exception)
Default handling of startup exceptions.
|
Micronaut |
include(java.lang.String... configurations)
Allow customizing the configurations that will be loaded.
|
Micronaut |
mainClass(java.lang.Class mainClass)
The main class used by this application.
|
<T extends java.lang.Throwable> |
mapError(java.lang.Class<T> exception,
java.util.function.Function<T,java.lang.Integer> mapper)
Maps an exception to the given error code.
|
Micronaut |
packages(java.lang.String... packages)
The packages to include for package scanning.
|
Micronaut |
properties(java.util.Map<java.lang.String,java.lang.Object> properties)
Properties to override from the environment.
|
Micronaut |
propertySources(PropertySource... propertySources)
Additional property sources.
|
static ApplicationContext |
run(java.lang.Class[] classes,
java.lang.String... args)
Run the application for the given arguments.
|
static ApplicationContext |
run(java.lang.Class cls,
java.lang.String... args)
Run the application for the given arguments.
|
static ApplicationContext |
run(java.lang.String... args)
Run the application for the given arguments.
|
Micronaut |
singletons(java.lang.Object... beans)
Additional singletons to register prior to startup.
|
ApplicationContext |
start()
Starts the
ApplicationContext . |
build, deduceEnvironment, eagerInitAnnotated, getClassLoader, getDeduceEnvironments, getEagerInitAnnotated, getEnvironments, getEnvironmentVariableExcludes, getEnvironmentVariableIncludes, getOverrideConfigLocations, getResourceLoader, isEnvironmentPropertySource, newApplicationContext, overrideConfigLocations
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
build, deduceEnvironment, eagerInitAnnotated, eagerInitConfiguration, eagerInitSingletons, overrideConfigLocations, run
getConversionService
isEagerInitConfiguration, isEagerInitSingletons
@NonNull public ApplicationContext start()
ApplicationContextBuilder
ApplicationContext
.start
in interface ApplicationContextBuilder
Micronaut
@NonNull public Micronaut include(@Nullable java.lang.String... configurations)
DefaultApplicationContextBuilder
include
in interface ApplicationContextBuilder
include
in class DefaultApplicationContextBuilder
configurations
- The configurations to include@NonNull public Micronaut exclude(@Nullable java.lang.String... configurations)
DefaultApplicationContextBuilder
exclude
in interface ApplicationContextBuilder
exclude
in class DefaultApplicationContextBuilder
configurations
- The configurations to exclude@NonNull public Micronaut classes(@Nullable java.lang.Class... classes)
classes
- The application@NonNull public Micronaut properties(@Nullable java.util.Map<java.lang.String,java.lang.Object> properties)
ApplicationContextBuilder
properties
in interface ApplicationContextBuilder
properties
in class DefaultApplicationContextBuilder
properties
- The properties@NonNull public Micronaut singletons(java.lang.Object... beans)
ApplicationContextBuilder
singletons
in interface ApplicationContextBuilder
singletons
in class DefaultApplicationContextBuilder
beans
- The beans@NonNull public Micronaut propertySources(@Nullable PropertySource... propertySources)
ApplicationContextBuilder
propertySources
in interface ApplicationContextBuilder
propertySources
in class DefaultApplicationContextBuilder
propertySources
- The property sources to include@NonNull public Micronaut environmentPropertySource(boolean environmentPropertySource)
ApplicationContextBuilder
environmentPropertySource
in interface ApplicationContextBuilder
environmentPropertySource
in class DefaultApplicationContextBuilder
environmentPropertySource
- The boolean@NonNull public Micronaut environmentVariableIncludes(@Nullable java.lang.String... environmentVariables)
ApplicationContextBuilder
environmentVariableIncludes
in interface ApplicationContextBuilder
environmentVariableIncludes
in class DefaultApplicationContextBuilder
environmentVariables
- The environment variables@NonNull public Micronaut environmentVariableExcludes(@Nullable java.lang.String... environmentVariables)
ApplicationContextBuilder
environmentVariableExcludes
in interface ApplicationContextBuilder
environmentVariableExcludes
in class DefaultApplicationContextBuilder
environmentVariables
- The environment variables@NonNull public Micronaut mainClass(java.lang.Class mainClass)
ApplicationContextBuilder
mainClass
in interface ApplicationContextBuilder
mainClass
in class DefaultApplicationContextBuilder
mainClass
- The main class@NonNull public Micronaut classLoader(java.lang.ClassLoader classLoader)
ApplicationContextBuilder
classLoader
in interface ApplicationContextBuilder
classLoader
in class DefaultApplicationContextBuilder
classLoader
- The classloader@NonNull public Micronaut args(@Nullable java.lang.String... args)
ApplicationContextBuilder
args
in interface ApplicationContextBuilder
args
in class DefaultApplicationContextBuilder
args
- The arguments@NonNull public Micronaut environments(@Nullable java.lang.String... environments)
ApplicationContextBuilder
environments
in interface ApplicationContextBuilder
environments
in class DefaultApplicationContextBuilder
environments
- The environments@NonNull public Micronaut packages(@Nullable java.lang.String... packages)
ApplicationContextBuilder
packages
in interface ApplicationContextBuilder
packages
in class DefaultApplicationContextBuilder
packages
- The packagespublic <T extends java.lang.Throwable> Micronaut mapError(java.lang.Class<T> exception, java.util.function.Function<T,java.lang.Integer> mapper)
T
- The exception typeexception
- The exceptionmapper
- The mapperpublic static Micronaut build(java.lang.String... args)
args
- The argumentsApplicationContext
public static ApplicationContext run(java.lang.String... args)
args
- The argumentsApplicationContext
public static ApplicationContext run(java.lang.Class cls, java.lang.String... args)
cls
- The application classargs
- The argumentsApplicationContext
public static ApplicationContext run(java.lang.Class[] classes, java.lang.String... args)
classes
- The application classesargs
- The argumentsApplicationContext
protected void handleStartupException(Environment environment, java.lang.Throwable exception)
environment
- The environmentexception
- The exceptionApplicationStartupException
- If the server cannot be shutdown with an appropriate exist code