basePackages property

List<String> basePackages
final

Annotation for Jetleaf component scanning.

@ComponentScan is used to instruct Jetleaf to scan specific packages or classes for annotated components (e.g., @Component, @Service, @Repository, @Controller) and automatically register them in the application context.

Key Features

  • Scans for annotated components in specified base packages or classes.
  • Allows inclusion or exclusion of classes using filters.
  • Supports default filters (e.g., built-in Jetleaf stereotypes).
  • Allows customizing name generation and scope resolution.

Usage

Developers apply this annotation at the configuration class level:

@ComponentScan(
  basePackages: ['com.example.myapp.services', 'com.example.myapp.repositories'],
  includeFilters: [
    ComponentScanFilter(
      type: FilterType.ANNOTATION,
      classes: [SpecialComponent],
    )
  ],
  excludeFilters: [
    ComponentScanFilter(
      type: FilterType.REGEX,
      pattern: '.*Internal.*'
    )
  ],
  useDefaultFilters: true,
)
class MyAppConfiguration {}

Notes

  • basePackages and basePackageClasses are mutually supportive: either specify string-based packages or anchor by class references.
  • Default filters include stereotypes like @Component, @Service, etc.
  • Advanced users can override scopeResolver and nameGenerator to plug in custom resolution or naming strategies.

Implementation

final List<String> basePackages;