
# spring_core_dart

The core package of Spring for Dart. You declare classes as beans with
annotations, and a container creates them, wires them together and
configures them. The wiring code is written by `spring_core_dart_generator`
at build time, so nothing is looked up by reflection at run time.

```yaml
dependencies:
  spring_core_dart: ^0.7.1

dev_dependencies:
  build_runner: ^2.17.0
  spring_core_dart_generator: ^0.7.1
```

```dart
import 'package:spring_core_dart/spring_core_dart.dart';

import 'main.spring.dart';

@Service()
class Greeter {
  Greeter(@Value(r'${greeting:Hello}') this.greeting);

  final String greeting;
}

@ComponentScan()
final BeanModule appBeans = $appBeans;

const log = SpringLog('app');

void main() {
  final context = ApplicationContext.run([appBeans]);
  log.info(context.getBean<Greeter>().greeting);
  context.close();
}
```

Run `dart run build_runner build` once, and again after you change the
annotations, to write `main.spring.dart`.

## What is inside

- [Container and beans](beans/index.md): the annotations that declare
  beans, inject them and manage their life, and the context that runs
  them.
- [Configuration](config/index.md): values from properties, YAML, the
  environment and the command line; profiles; typed settings.
- [Events](events/index.md): beans that publish and listen to events,
  synchronously or not.
- [Messages](messages/index.md): texts in several languages, with
  arguments.
- [Resources](resources/index.md): files, assets and URLs behind one
  interface; path patterns.
- [Type conversion](conversion/index.md): strings to numbers, durations,
  sizes and your own types.
- [Logging](logging/index.md): `SpringLog`, levels and the line format.
- [Expressions (SpEL)](spel/index.md): `#{...}` expressions in
  annotations and in code.
- [JSON](json/index.md): objects to JSON and back, with annotations.
- [Validation](validation/index.md): constraints on fields and
  parameters, and the validator.
- [Aspects (AOP)](aop/index.md): code that runs around the methods of
  beans.

## Libraries

`package:spring_core_dart/spring_core_dart.dart` exports everything. A
library that needs only one part can import it alone: `core.dart`,
`beans.dart`, `context.dart`, `expression.dart`, `json.dart`,
`validation.dart`, `aop.dart`. The Jakarta names (`@Inject`, `@Named`)
are in `jakarta.dart`.
