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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet the command line arguments.banner(boolean isEnabled) Whether the banner is enabled or not.beanDefinitions(@NonNull RuntimeBeanDefinition<?>... definitions) Register additional runtime bean definitions prior to startup.static MicronautRun 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 voidhandleStartupException(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 ApplicationContextRun the application for the given arguments.static ApplicationContextRun the application for the given arguments.static ApplicationContextRun 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, beanConfigurations, beanResolutionTrace, bootstrapEnvironment, build, deduceCloudEnvironment, deduceEnvironment, eagerInitAnnotated, enableDefaultPropertySources, getClassLoader, getContextConfigurer, getDeduceEnvironments, getDefaultEnvironments, getEagerInitAnnotated, getEnvironments, getEnvironmentVariableExcludes, getEnvironmentVariableIncludes, getOverrideConfigLocations, getResourceLoader, getTraceConfiguration, isAllowEmptyProviders, isBannerEnabled, isBootstrapEnvironmentEnabled, isDeduceCloudEnvironment, isEnableDefaultPropertySources, isEnvironmentPropertySource, newApplicationContext, overrideConfigLocationsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.micronaut.context.ApplicationContextBuilder
allowEmptyProviders, beanConfigurations, beanResolutionTrace, beanResolutionTrace, bootstrapEnvironment, build, deduceCloudEnvironment, deduceEnvironment, eagerInitAnnotated, eagerInitConfiguration, eagerInitSingletons, enableDefaultPropertySources, overrideConfigLocations, runMethods inherited from interface io.micronaut.context.ApplicationContextConfiguration
getConversionServiceMethods inherited from interface io.micronaut.context.BeanContextConfiguration
isEagerInitConfiguration, isEagerInitSingletons
-
Constructor Details
-
Micronaut
protected Micronaut()The default constructor.
-
-
Method Details
-
start
Description copied from interface:ApplicationContextBuilderStarts theApplicationContext.- Specified by:
startin interfaceApplicationContextBuilder- Returns:
- Run this
Micronaut
-
include
Description copied from class:DefaultApplicationContextBuilderAllow customizing the configurations that will be loaded.- Specified by:
includein interfaceApplicationContextBuilder- Overrides:
includein classDefaultApplicationContextBuilder- Parameters:
configurations- The configurations to include- Returns:
- This application
-
exclude
Description copied from class:DefaultApplicationContextBuilderAllow customizing the configurations that will be loaded.- Specified by:
excludein interfaceApplicationContextBuilder- Overrides:
excludein classDefaultApplicationContextBuilder- Parameters:
configurations- The configurations to exclude- Returns:
- This application
-
banner
Description copied from interface:ApplicationContextBuilderWhether the banner is enabled or not.- Specified by:
bannerin interfaceApplicationContextBuilder- Overrides:
bannerin 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:ApplicationContextBuilderProperties to override from the environment.- Specified by:
propertiesin interfaceApplicationContextBuilder- Overrides:
propertiesin classDefaultApplicationContextBuilder- Parameters:
properties- The properties- Returns:
- This builder
-
singletons
Description copied from interface:ApplicationContextBuilderAdditional singletons to register prior to startup.- Specified by:
singletonsin interfaceApplicationContextBuilder- Overrides:
singletonsin classDefaultApplicationContextBuilder- Parameters:
beans- The beans- Returns:
- This builder
-
beanDefinitions
Description copied from interface:ApplicationContextBuilderRegister additional runtime bean definitions prior to startup.- Specified by:
beanDefinitionsin interfaceApplicationContextBuilder- Overrides:
beanDefinitionsin classDefaultApplicationContextBuilder- Parameters:
definitions- The definitions.- Returns:
- The context builder
-
propertySources
@NonNull public @NonNull Micronaut propertySources(@Nullable @Nullable PropertySource... propertySources) Description copied from interface:ApplicationContextBuilderAdditional property sources.- Specified by:
propertySourcesin interfaceApplicationContextBuilder- Overrides:
propertySourcesin classDefaultApplicationContextBuilder- Parameters:
propertySources- The property sources to include- Returns:
- This builder
-
environmentPropertySource
Description copied from interface:ApplicationContextBuilderSet whether environment variables should contribute to configuration.- Specified by:
environmentPropertySourcein interfaceApplicationContextBuilder- Overrides:
environmentPropertySourcein classDefaultApplicationContextBuilder- Parameters:
environmentPropertySource- The boolean- Returns:
- This builder
-
environmentVariableIncludes
@NonNull public @NonNull Micronaut environmentVariableIncludes(@Nullable @Nullable String... environmentVariables) Description copied from interface:ApplicationContextBuilderWhich environment variables should contribute to configuration.- Specified by:
environmentVariableIncludesin interfaceApplicationContextBuilder- Overrides:
environmentVariableIncludesin classDefaultApplicationContextBuilder- Parameters:
environmentVariables- The environment variables- Returns:
- This builder
-
environmentVariableExcludes
@NonNull public @NonNull Micronaut environmentVariableExcludes(@Nullable @Nullable String... environmentVariables) Description copied from interface:ApplicationContextBuilderWhich environment variables should not contribute to configuration.- Specified by:
environmentVariableExcludesin interfaceApplicationContextBuilder- Overrides:
environmentVariableExcludesin classDefaultApplicationContextBuilder- Parameters:
environmentVariables- The environment variables- Returns:
- This builder
-
mainClass
Description copied from interface:ApplicationContextBuilderThe main class used by this application.- Specified by:
mainClassin interfaceApplicationContextBuilder- Overrides:
mainClassin classDefaultApplicationContextBuilder- Parameters:
mainClass- The main class- Returns:
- This builder
-
classLoader
Description copied from interface:ApplicationContextBuilderThe class loader to be used.- Specified by:
classLoaderin interfaceApplicationContextBuilder- Overrides:
classLoaderin classDefaultApplicationContextBuilder- Parameters:
classLoader- The classloader- Returns:
- This builder
-
args
Description copied from interface:ApplicationContextBuilderSet the command line arguments.- Specified by:
argsin interfaceApplicationContextBuilder- Overrides:
argsin classDefaultApplicationContextBuilder- Parameters:
args- The arguments- Returns:
- This application
-
environments
Description copied from interface:ApplicationContextBuilderThe environments to use.- Specified by:
environmentsin interfaceApplicationContextBuilder- Overrides:
environmentsin classDefaultApplicationContextBuilder- Parameters:
environments- The environments- Returns:
- This builder
-
defaultEnvironments
Description copied from interface:ApplicationContextBuilderThe environments to use if no other environments are specified.- Specified by:
defaultEnvironmentsin interfaceApplicationContextBuilder- Overrides:
defaultEnvironmentsin classDefaultApplicationContextBuilder- Parameters:
environments- The environments- Returns:
- This builder
-
packages
Description copied from interface:ApplicationContextBuilderThe packages to include for package scanning.- Specified by:
packagesin interfaceApplicationContextBuilder- Overrides:
packagesin 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
-