Package io.micronaut.runtime
Class Micronaut
java.lang.Object
io.micronaut.context.DefaultApplicationContextBuilder
io.micronaut.runtime.Micronaut
- All Implemented Interfaces:
ApplicationContextBuilder
,ApplicationContextConfiguration
,BeanContextConfiguration
public class Micronaut
extends DefaultApplicationContextBuilder
implements ApplicationContextBuilder
Main entry point for running a Micronaut application.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionSet the command line arguments.banner
(boolean isEnabled) Whether the banner is enabled or not.static Micronaut
Run the application for the given arguments.Add classes to be included in the initialization of the application.classLoader
(ClassLoader classLoader) The class loader to be used.defaultEnvironments
(@Nullable String... environments) The environments to use if no other environments are specified.environmentPropertySource
(boolean environmentPropertySource) Set whether environment variables should contribute to configuration.environments
(@Nullable String... environments) The environments to use.environmentVariableExcludes
(@Nullable String... environmentVariables) Which environment variables should not contribute to configuration.environmentVariableIncludes
(@Nullable String... environmentVariables) Which environment variables should contribute to configuration.Allow customizing the configurations that will be loaded.protected void
handleStartupException
(Environment environment, Throwable exception) Default handling of startup exceptions.Allow customizing the configurations that will be loaded.The main class used by this application.Maps an exception to the given error code.The packages to include for package scanning.properties
(@Nullable Map<String, Object> properties) Properties to override from the environment.propertySources
(@Nullable PropertySource... propertySources) Additional property sources.static ApplicationContext
Run the application for the given arguments.static ApplicationContext
Run the application for the given arguments.static ApplicationContext
Run the application for the given arguments.singletons
(Object... beans) Additional singletons to register prior to startup.start()
Starts theApplicationContext
.Methods inherited from class io.micronaut.context.DefaultApplicationContextBuilder
allowEmptyProviders, bootstrapEnvironment, build, deduceCloudEnvironment, deduceEnvironment, eagerInitAnnotated, enableDefaultPropertySources, getClassLoader, getDeduceEnvironments, getDefaultEnvironments, getEagerInitAnnotated, getEnvironments, getEnvironmentVariableExcludes, getEnvironmentVariableIncludes, getOverrideConfigLocations, getResourceLoader, isAllowEmptyProviders, isBannerEnabled, isBootstrapEnvironmentEnabled, isDeduceCloudEnvironment, isEnableDefaultPropertySources, isEnvironmentPropertySource, newApplicationContext, overrideConfigLocations
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.context.ApplicationContextBuilder
allowEmptyProviders, bootstrapEnvironment, build, deduceCloudEnvironment, deduceEnvironment, eagerInitAnnotated, eagerInitConfiguration, eagerInitSingletons, enableDefaultPropertySources, overrideConfigLocations, run
Methods inherited from interface io.micronaut.context.ApplicationContextConfiguration
getConversionService
Methods inherited from interface io.micronaut.context.BeanContextConfiguration
isEagerInitConfiguration, isEagerInitSingletons
-
Constructor Details
-
Micronaut
protected Micronaut()The default constructor.
-
-
Method Details
-
start
Description copied from interface:ApplicationContextBuilder
Starts theApplicationContext
.- Specified by:
start
in interfaceApplicationContextBuilder
- Returns:
- Run this
Micronaut
-
include
Description copied from class:DefaultApplicationContextBuilder
Allow customizing the configurations that will be loaded.- Specified by:
include
in interfaceApplicationContextBuilder
- Overrides:
include
in classDefaultApplicationContextBuilder
- Parameters:
configurations
- The configurations to include- Returns:
- This application
-
exclude
Description copied from class:DefaultApplicationContextBuilder
Allow customizing the configurations that will be loaded.- Specified by:
exclude
in interfaceApplicationContextBuilder
- Overrides:
exclude
in classDefaultApplicationContextBuilder
- Parameters:
configurations
- The configurations to exclude- Returns:
- This application
-
banner
Description copied from interface:ApplicationContextBuilder
Whether the banner is enabled or not.- Specified by:
banner
in interfaceApplicationContextBuilder
- Overrides:
banner
in classDefaultApplicationContextBuilder
- Parameters:
isEnabled
- Whether the banner is enabled or not- Returns:
- This application
-
classes
Add classes to be included in the initialization of the application.- Parameters:
classes
- The application- Returns:
- The classes
-
properties
Description copied from interface:ApplicationContextBuilder
Properties to override from the environment.- Specified by:
properties
in interfaceApplicationContextBuilder
- Overrides:
properties
in classDefaultApplicationContextBuilder
- Parameters:
properties
- The properties- Returns:
- This builder
-
singletons
Description copied from interface:ApplicationContextBuilder
Additional singletons to register prior to startup.- Specified by:
singletons
in interfaceApplicationContextBuilder
- Overrides:
singletons
in classDefaultApplicationContextBuilder
- Parameters:
beans
- The beans- Returns:
- This builder
-
propertySources
@NonNull public @NonNull Micronaut propertySources(@Nullable @Nullable PropertySource... propertySources) Description copied from interface:ApplicationContextBuilder
Additional property sources.- Specified by:
propertySources
in interfaceApplicationContextBuilder
- Overrides:
propertySources
in classDefaultApplicationContextBuilder
- Parameters:
propertySources
- The property sources to include- Returns:
- This builder
-
environmentPropertySource
Description copied from interface:ApplicationContextBuilder
Set whether environment variables should contribute to configuration.- Specified by:
environmentPropertySource
in interfaceApplicationContextBuilder
- Overrides:
environmentPropertySource
in classDefaultApplicationContextBuilder
- Parameters:
environmentPropertySource
- The boolean- Returns:
- This builder
-
environmentVariableIncludes
@NonNull public @NonNull Micronaut environmentVariableIncludes(@Nullable @Nullable String... environmentVariables) Description copied from interface:ApplicationContextBuilder
Which environment variables should contribute to configuration.- Specified by:
environmentVariableIncludes
in interfaceApplicationContextBuilder
- Overrides:
environmentVariableIncludes
in classDefaultApplicationContextBuilder
- Parameters:
environmentVariables
- The environment variables- Returns:
- This builder
-
environmentVariableExcludes
@NonNull public @NonNull Micronaut environmentVariableExcludes(@Nullable @Nullable String... environmentVariables) Description copied from interface:ApplicationContextBuilder
Which environment variables should not contribute to configuration.- Specified by:
environmentVariableExcludes
in interfaceApplicationContextBuilder
- Overrides:
environmentVariableExcludes
in classDefaultApplicationContextBuilder
- Parameters:
environmentVariables
- The environment variables- Returns:
- This builder
-
mainClass
Description copied from interface:ApplicationContextBuilder
The main class used by this application.- Specified by:
mainClass
in interfaceApplicationContextBuilder
- Overrides:
mainClass
in classDefaultApplicationContextBuilder
- Parameters:
mainClass
- The main class- Returns:
- This builder
-
classLoader
Description copied from interface:ApplicationContextBuilder
The class loader to be used.- Specified by:
classLoader
in interfaceApplicationContextBuilder
- Overrides:
classLoader
in classDefaultApplicationContextBuilder
- Parameters:
classLoader
- The classloader- Returns:
- This builder
-
args
Description copied from interface:ApplicationContextBuilder
Set the command line arguments.- Specified by:
args
in interfaceApplicationContextBuilder
- Overrides:
args
in classDefaultApplicationContextBuilder
- Parameters:
args
- The arguments- Returns:
- This application
-
environments
Description copied from interface:ApplicationContextBuilder
The environments to use.- Specified by:
environments
in interfaceApplicationContextBuilder
- Overrides:
environments
in classDefaultApplicationContextBuilder
- Parameters:
environments
- The environments- Returns:
- This builder
-
defaultEnvironments
Description copied from interface:ApplicationContextBuilder
The environments to use if no other environments are specified.- Specified by:
defaultEnvironments
in interfaceApplicationContextBuilder
- Overrides:
defaultEnvironments
in classDefaultApplicationContextBuilder
- Parameters:
environments
- The environments- Returns:
- This builder
-
packages
Description copied from interface:ApplicationContextBuilder
The packages to include for package scanning.- Specified by:
packages
in interfaceApplicationContextBuilder
- Overrides:
packages
in classDefaultApplicationContextBuilder
- Parameters:
packages
- The packages- Returns:
- This builder
-
mapError
Maps an exception to the given error code.- Type Parameters:
T
- The exception type- Parameters:
exception
- The exceptionmapper
- The mapper- Returns:
- This application
-
build
Run the application for the given arguments. Classes for the application will be discovered automatically- Parameters:
args
- The arguments- Returns:
- The
ApplicationContext
-
run
Run the application for the given arguments. Classes for the application will be discovered automatically- Parameters:
args
- The arguments- Returns:
- The
ApplicationContext
-
run
Run the application for the given arguments.- Parameters:
cls
- The application classargs
- The arguments- Returns:
- The
ApplicationContext
-
run
Run the application for the given arguments.- Parameters:
classes
- The application classesargs
- The arguments- Returns:
- The
ApplicationContext
-
handleStartupException
Default handling of startup exceptions.- Parameters:
environment
- The environmentexception
- The exception- Throws:
ApplicationStartupException
- If the server cannot be shutdown with an appropriate exist code
-