@Description

@Description('...') gives a bean a human-readable description.

Why

The text is stored in the bean definition (BeanDefinition.description). Tools and diagnostics that list beans can show it, for example an actuator endpoint or your own startup report. It changes nothing in how the bean is created or injected.

Use it when the bean name alone does not tell an operator what the bean does. Most beans do not need it.

Example

import 'package:spring_core_dart/spring_core_dart.dart';

@Component()
@Description('Sends transactional e-mails')
class Mailer {
  void send(String to, String subject) {}
}

const log = SpringLog('app');

// Lists every bean with its description.
void logBeans(ConfigurableApplicationContext context) {
  final factory = context.beanFactory;
  for (final name in factory.beanDefinitionNames) {
    final description = factory.getBeanDefinition(name).description;
    log.info('$name: ${description ?? '-'}');
  }
}

Parameters

Name Type Default Meaning
value (positional) String required The description text.

In Spring (Java)

@Component
@Description("Sends transactional e-mails")
class Mailer { ... }

The meaning is the same.

See also