@Configuration و@Bean
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
register beans you cannot annotate.
الموضوعات المخطط لها
- Use
@Beanmethods when the class is third-party or needs set-up code. - Put them in a class marked
@Configuration. - The method name is the bean name; the return type is the bean type.
- Parameters of a
@Beanmethod are injected like constructor parameters.
تفاصيل المخطط المبدئي
عرض عملي
@Configuration
class AppConfig {
@Bean Clock clock() { return Clock.systemUTC(); }
}اختبر فهمك
When @Bean instead of @Component?
أظهر الإجابة
When you cannot edit the class, or it needs custom construction.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.