Resource class
Injects a field or setter with the bean of a given name: the JSR-250
annotation jakarta.annotation.Resource.
Where @Autowired() chooses by type, @Resource chooses by name, which
helps when many beans share a type (several DataSources, say).
Without name the field or setter name is the bean name; when no bean
has that name the point is injected by type like @Autowired (Spring's
fallbackToDefaultTypeMatch). An explicit name must name a bean (an
alias or &factory works too) of the point's type. A nullable point
receives null when the bean is missing.
import 'package:spring_core_dart/jakarta.dart' as jakarta;
// Two stores exist; the archive one is wanted here.
@Service()
class Reports {
@jakarta.Resource()
late final DataSource dataSource; // bean 'dataSource', else by type
@jakarta.Resource(name: 'archiveStore')
late final Store store; // exactly the bean 'archiveStore'
}
Spring (Java):
@Service
class Reports {
@Resource DataSource dataSource;
@Resource(name = "archiveStore") Store store;
}
Differences from Spring: fields and setters only (no @Resource
methods with other names, no type, lookup or JNDI attributes).
Constructors
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited