1. Create a new Maven project in Eclipse: a. File -> New Maven Project b. Click "Create a simple project (skip archetype selection), then press Next c. Fill in the following, leaving rest as default: GroupID: SpringTraining ArtifactID: SpringWrapup Parent GroupID: org.springframework.boot Parent ArtifactID: spring-boot-starter-parent Parent Version: 3.3.3 Press Finish. 2. Copying and pasting from earlier lab POMs, add the following to the new pom.xml: - In set the Java version number to 21. - In , add elements for these artifacts: - spring-boot-starter-data-jpa - spring-boot-starter-test - derby - derbytools - derbyclient - spring-boot-starter-web - tomcat-embed-jasper - Update the Maven project 3. In src/main/java, create a new class with a main() method named BootRestApplication in a new package named com.wrapup, then complete the class: - Annotate the class so it's a Spring boot application - In main(), call SpringApplication.run() 4. As a quick test, run BootRestApplication as a Java application and look in the console to make sure that everything looks OK and that the embedded Tomcat started. Stop the application before continuing. 5. In a new Java package named com.wrapup.domain, create a class that represents a segment of air travel named Segment, then complete the class: - Add the following fields: private Long segmentNumber; private java.time.LocalDate segmentDate; private int flightNumber; private String originatingCity; private int miles; - Generate get/set methods - Generate a toString() method - Annotate the class so it can work as a JPA entity using the segmentNumber as an IDENTITY primary key 6. In the src/main/resources folder, create a file named schema.sql with the following: CREATE TABLE Segment ( segmentNumber BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), segmentDate DATE, flightNumber INTEGER, originatingCity VARCHAR(50), miles INTEGER, CONSTRAINT PK_Item PRIMARY KEY(segmentNumber) ); 7. In the src/main/resources folder, create a file named data.sql with the following: INSERT INTO Segment VALUES (DEFAULT, '2009-10-18', 333, 'SFO', 367); INSERT INTO Segment VALUES (DEFAULT, '2009-10-18', 745, 'LAX', 1900); INSERT INTO Segment VALUES (DEFAULT, '2009-10-22', 453, 'BOS', 1900); INSERT INTO Segment VALUES (DEFAULT, '2009-10-18', 112, 'LAX', 367); 8. Run the program again and look in the Console to ensure that's working so far (ignore the usual FeatureNotImplement stack trace). 9. In a new Java package named com.wrapup.persistence, create an interface named SegmentRepository, and add method signatures to: - get all Segments - find a Segment give its segmentNumber Feel free to add other CRUD methods like insert() and update()! 10. In the same package, create a class named JpaSegmentRepositoryImpl that implements the SegmentRepository interface. Complete as many of the methods that you can, starting with getAllSegments() and findSegment(). Look at code from previous labs for inspiration. You will need to autowire an EntityManager! 11. In a new com.wrapup.config package, create a class named RespositoryConfig and complete it so it's a Java configuration class that returns a bean of type SegmentRepository. Be sure to add an @EntityScan to the class to pick up the Segment entity you coded previously. 12. Edit the BootRestApplication main() class and ensure that it imports the the new RepositoryConfig class. 13. Using previous labs for inspiration, in src/test/java, write a Spring testing class and unit tests for the repository methods that you've implemented. Do not continue until all of the tests pass. 14. In a new package named com.wrapup.rest, create a class named SegmentResource and complete it: - Annotate it as a RestController - Write an annotation on the class to establish a class-level URI of "/segments". - Autowire a reference to the SegmentRepository - Write at least two REST methods, one that returns all Segments and one that returns a Segment given its segmentNumber. Feel free to write additional CRUD methods that match your SegmentRepository! 15. Run the main() class and then use a browser to test that your application returns JSON for all segments and an individual segment.