XML, Annotation-Based and Java-Based Configuration
Learn XML, Annotation-Based and Java-Based Configuration (Phase 4 · Spring Configuration (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
The three configuration styles • XML-based (original): <beans> with <bean id class> , <constructor-arg> , <property> , <import resource> , <context:component-scan> , <context:property-placeholder> . Externalises wiring from code; verbose; still found in legacy systems; loaded with ClassPathXmlApplicationContext . • Annotation-based : stereotypes ( @Component ...) discovered by component scanning , wired with @Autowired / @Value ; concise; configuration lives next to the code. • Java-based (modern, recommended for infrastructure): @Configuration classes with @Bean factory methods; type-safe,...