Spring Boot Bootcamp – Workbooks and Challenges
)}

Workbook 5.1

In the olden days, it was only possible to configure beans using XML.

Launch the starter project

Screen Shot 2022-08-16 at 1.36.20 AM.png

Task 1

Create an app-config.xml file inside /src/main/resources.

Task 2

Use the following template to configure the Service and Repository beans.

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="choose a name for the bean" class="path to class"> </bean> <bean id="choose a name for the bean" class="path to class"> </bean> </beans>

An example of a path is: com.organization.artifactid.folder.ClassName

Task 3

There is an AppConfig class inside the source code. It has already been configured to scan for beans inside app-config.xml.

@Configuration @ImportResource("app-config.xml") public class AppConfig { }

Task 4

Remove the @Service and @Repository annotations, otherwise Spring Boot will throw an exception. The beans are already being configured inside app-config.xml.


Final Remarks: I prefer the Java implementation.

Feedback Summary
5.0
3 students
5

100%
4

0%
3

0%
2

0%
1

0%
Written Reviews
There are no written reviews yet.