Class Micronaut

java.lang.Object
io.micronaut.context.DefaultApplicationContextBuilder
io.micronaut.runtime.Micronaut
All Implemented Interfaces:
io.micronaut.context.ApplicationContextBuilder, io.micronaut.context.ApplicationContextConfiguration, io.micronaut.context.BeanContextConfiguration

@NullMarked public class Micronaut extends io.micronaut.context.DefaultApplicationContextBuilder implements io.micronaut.context.ApplicationContextBuilder

Main entry point for running a Micronaut application.

Since:
1.0
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    The default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    args(String @Nullable ... args)
     
    banner(boolean isEnabled)
     
    beanDefinitions(io.micronaut.context.RuntimeBeanDefinition<?>... definitions)
     
    static Micronaut
    build(String... args)
    Run the application for the given arguments.
    classes(@Nullable Class<?>... classes)
    Add classes to be included in the initialization of the application.
    classLoader(@Nullable ClassLoader classLoader)
     
    configurationLoadingStrategy(io.micronaut.core.io.ResourceLoadStrategy.Builder builder)
     
    defaultEnvironments(String @Nullable ... environments)
     
    environmentPropertySource(boolean environmentPropertySource)
     
    environments(String @Nullable ... environments)
     
    environmentVariableExcludes(String @Nullable ... environmentVariables)
     
    environmentVariableIncludes(String @Nullable ... environmentVariables)
     
    exclude(String @Nullable ... configurations)
     
    protected void
    handleStartupException(io.micronaut.context.env.Environment environment, Throwable exception)
    Default handling of startup exceptions.
    include(String @Nullable ... configurations)
     
    mainClass(@Nullable Class<?> mainClass)
     
    <T extends Throwable>
    Micronaut
    mapError(Class<T> exception, Function<T,Integer> mapper)
    Maps an exception to the given error code.
    packages(String @Nullable ... packages)
     
    properties(@Nullable Map<String,Object> properties)
     
    propertySources(io.micronaut.context.env.PropertySource @Nullable ... propertySources)
     
    static io.micronaut.context.ApplicationContext
    run(Class<?>[] classes, String... args)
    Run the application for the given arguments.
    static io.micronaut.context.ApplicationContext
    run(Class<?> cls, String... args)
    Run the application for the given arguments.
    static io.micronaut.context.ApplicationContext
    run(String... args)
    Run the application for the given arguments.
    singletons(Object @Nullable ... beans)
     
    io.micronaut.context.ApplicationContext
     

    Methods inherited from class io.micronaut.context.DefaultApplicationContextBuilder

    allowEmptyProviders, beanConfiguraionsPredicate, beanConfigurations, beanConfigurationsPredicate, beanDefinitionsProvider, beanResolutionCustomizer, beanResolutionCustomizer, beanResolutionTrace, beansPredicate, beansPredicate, bootstrapEnvironment, build, configImport, customScopeRegistry, customScopeRegistryFactory, deduceCloudEnvironment, deduceEnvironment, deducePackage, eagerBeansEnabled, eagerBeansEnabled, eagerInitAnnotated, enableDefaultPropertySources, eventsEnabled, eventsEnabled, getBeanDefinitionsProvider, getClassLoader, getConfigurationLoadingStrategy, getContextConfigurer, getDeduceEnvironments, getDefaultEnvironments, getEagerInitAnnotated, getEnvironments, getEnvironmentVariableExcludes, getEnvironmentVariableIncludes, getOverrideConfigLocations, getPropertySourcesLocators, getResourceLoader, getTraceConfiguration, isAllowEmptyProviders, isBannerEnabled, isBootstrapEnvironmentEnabled, isConfigImportEnabled, isDeduceCloudEnvironment, isDeducePackage, isEnableDefaultPropertySources, isEnvironmentPropertySource, newApplicationContext, overrideConfigLocations, propertySourcesLocator, resourceResolver

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.context.ApplicationContextBuilder

    allowEmptyProviders, beanConfigurations, beanConfigurationsPredicate, beanDefinitionsProvider, beanResolutionCustomizer, beanResolutionTrace, beanResolutionTrace, beansPredicate, bootstrapEnvironment, build, configImport, customScopeRegistry, deduceCloudEnvironment, deduceEnvironment, deducePackage, eagerBeansEnabled, eagerInitAnnotated, eagerInitConfiguration, eagerInitSingletons, enableDefaultPropertySources, eventsEnabled, overrideConfigLocations, propertySourcesLocator, resourceResolver, run

    Methods inherited from interface io.micronaut.context.ApplicationContextConfiguration

    getApplicationName, getConversionService, getEnvironmentNamesDeducer, getPackageDeducer

    Methods inherited from interface io.micronaut.context.BeanContextConfiguration

    isEagerInitConfiguration, isEagerInitSingletons
  • Constructor Details

    • Micronaut

      protected Micronaut()
      The default constructor.
  • Method Details

    • start

      public io.micronaut.context.ApplicationContext start()
      Specified by:
      start in interface io.micronaut.context.ApplicationContextBuilder
      Returns:
      Run this Micronaut
    • include

      public Micronaut include(String @Nullable ... configurations)
      Specified by:
      include in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      include in class io.micronaut.context.DefaultApplicationContextBuilder
    • exclude

      public Micronaut exclude(String @Nullable ... configurations)
      Specified by:
      exclude in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      exclude in class io.micronaut.context.DefaultApplicationContextBuilder
    • banner

      public Micronaut banner(boolean isEnabled)
      Specified by:
      banner in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      banner in class io.micronaut.context.DefaultApplicationContextBuilder
    • classes

      public Micronaut classes(@Nullable Class<?>... classes)
      Add classes to be included in the initialization of the application.
      Parameters:
      classes - The application
      Returns:
      The classes
    • properties

      public Micronaut properties(@Nullable Map<String,Object> properties)
      Specified by:
      properties in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      properties in class io.micronaut.context.DefaultApplicationContextBuilder
    • singletons

      public Micronaut singletons(Object @Nullable ... beans)
      Specified by:
      singletons in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      singletons in class io.micronaut.context.DefaultApplicationContextBuilder
    • beanDefinitions

      public Micronaut beanDefinitions(io.micronaut.context.RuntimeBeanDefinition<?>... definitions)
      Specified by:
      beanDefinitions in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      beanDefinitions in class io.micronaut.context.DefaultApplicationContextBuilder
    • propertySources

      public Micronaut propertySources(io.micronaut.context.env.PropertySource @Nullable ... propertySources)
      Specified by:
      propertySources in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      propertySources in class io.micronaut.context.DefaultApplicationContextBuilder
    • environmentPropertySource

      public Micronaut environmentPropertySource(boolean environmentPropertySource)
      Specified by:
      environmentPropertySource in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      environmentPropertySource in class io.micronaut.context.DefaultApplicationContextBuilder
    • environmentVariableIncludes

      public Micronaut environmentVariableIncludes(String @Nullable ... environmentVariables)
      Specified by:
      environmentVariableIncludes in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      environmentVariableIncludes in class io.micronaut.context.DefaultApplicationContextBuilder
    • environmentVariableExcludes

      public Micronaut environmentVariableExcludes(String @Nullable ... environmentVariables)
      Specified by:
      environmentVariableExcludes in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      environmentVariableExcludes in class io.micronaut.context.DefaultApplicationContextBuilder
    • mainClass

      public Micronaut mainClass(@Nullable Class<?> mainClass)
      Specified by:
      mainClass in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      mainClass in class io.micronaut.context.DefaultApplicationContextBuilder
    • classLoader

      public Micronaut classLoader(@Nullable ClassLoader classLoader)
      Specified by:
      classLoader in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      classLoader in class io.micronaut.context.DefaultApplicationContextBuilder
    • args

      public Micronaut args(String @Nullable ... args)
      Specified by:
      args in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      args in class io.micronaut.context.DefaultApplicationContextBuilder
    • environments

      public Micronaut environments(String @Nullable ... environments)
      Specified by:
      environments in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      environments in class io.micronaut.context.DefaultApplicationContextBuilder
    • configurationLoadingStrategy

      public Micronaut configurationLoadingStrategy(io.micronaut.core.io.ResourceLoadStrategy.Builder builder)
      Specified by:
      configurationLoadingStrategy in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      configurationLoadingStrategy in class io.micronaut.context.DefaultApplicationContextBuilder
    • defaultEnvironments

      public Micronaut defaultEnvironments(String @Nullable ... environments)
      Specified by:
      defaultEnvironments in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      defaultEnvironments in class io.micronaut.context.DefaultApplicationContextBuilder
    • packages

      public Micronaut packages(String @Nullable ... packages)
      Specified by:
      packages in interface io.micronaut.context.ApplicationContextBuilder
      Overrides:
      packages in class io.micronaut.context.DefaultApplicationContextBuilder
    • mapError

      public <T extends Throwable> Micronaut mapError(Class<T> exception, Function<T,Integer> mapper)
      Maps an exception to the given error code.
      Type Parameters:
      T - The exception type
      Parameters:
      exception - The exception
      mapper - The mapper
      Returns:
      This application
    • build

      public static Micronaut build(String... args)
      Run the application for the given arguments. Classes for the application will be discovered automatically
      Parameters:
      args - The arguments
      Returns:
      The ApplicationContext
    • run

      public static io.micronaut.context.ApplicationContext run(String... args)
      Run the application for the given arguments. Classes for the application will be discovered automatically
      Parameters:
      args - The arguments
      Returns:
      The ApplicationContext
    • run

      public static io.micronaut.context.ApplicationContext run(Class<?> cls, String... args)
      Run the application for the given arguments.
      Parameters:
      cls - The application class
      args - The arguments
      Returns:
      The ApplicationContext
    • run

      public static io.micronaut.context.ApplicationContext run(Class<?>[] classes, String... args)
      Run the application for the given arguments.
      Parameters:
      classes - The application classes
      args - The arguments
      Returns:
      The ApplicationContext
    • handleStartupException

      protected void handleStartupException(io.micronaut.context.env.Environment environment, Throwable exception)
      Default handling of startup exceptions.
      Parameters:
      environment - The environment
      exception - The exception
      Throws:
      ApplicationStartupException - If the server cannot be shutdown with an appropriate exist code