From 550a2789db82286a615f57b179360083e976e84a Mon Sep 17 00:00:00 2001 From: Mary Ellen Bowman Date: Mon, 1 Apr 2024 02:21:38 +0000 Subject: [PATCH 1/6] initil simple app --- .gitignore | 3 ++ tour-service/pom.xml | 16 +++++++++++ .../main/java/com/example/Application.java | 13 +++++++++ .../java/com/example/tourservice/Tour.java | 13 +++++++++ .../com/example/tourservice/TourType.java | 15 ++++++++++ .../utilities/TourInitializer.java | 22 +++++++++++++++ .../tourservice/utilities/TourRepository.java | 28 +++++++++++++++++++ .../utilities/TravelAgentService.java | 12 ++++++++ 8 files changed, 122 insertions(+) create mode 100644 tour-service/pom.xml create mode 100644 tour-service/src/main/java/com/example/Application.java create mode 100644 tour-service/src/main/java/com/example/tourservice/Tour.java create mode 100644 tour-service/src/main/java/com/example/tourservice/TourType.java create mode 100644 tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java create mode 100644 tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java create mode 100644 tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java diff --git a/.gitignore b/.gitignore index 4b64bc3..c241cd4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ node_modules .tmp npm-debug.log +*.class +*.jar +tour-service/target diff --git a/tour-service/pom.xml b/tour-service/pom.xml new file mode 100644 index 0000000..49127f4 --- /dev/null +++ b/tour-service/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + + org.example + tour-service + 1.0.0 + + + 21 + 21 + UTF-8 + + \ No newline at end of file diff --git a/tour-service/src/main/java/com/example/Application.java b/tour-service/src/main/java/com/example/Application.java new file mode 100644 index 0000000..762a420 --- /dev/null +++ b/tour-service/src/main/java/com/example/Application.java @@ -0,0 +1,13 @@ +package com.example; +import com.example.tourservice.utilities.TourInitializer; +import com.example.tourservice.utilities.TourRepository; +import com.example.tourservice.utilities.TravelAgentService; + +public class Application { + public static void main(String[] args) { + TourRepository tr = new TourRepository(); + TourInitializer as = new TourInitializer(tr); + TravelAgentService agentService = new TravelAgentService(tr); + agentService.display(); + } +} \ No newline at end of file diff --git a/tour-service/src/main/java/com/example/tourservice/Tour.java b/tour-service/src/main/java/com/example/tourservice/Tour.java new file mode 100644 index 0000000..71460f7 --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/Tour.java @@ -0,0 +1,13 @@ +package com.example.tourservice; + +/** + * The Tour contains all attributes of an Explore California Tour. + * + * Created by Mary Ellen Bowman + */ +public record Tour(String title, Integer price, TourType type) { + @Override + public String toString() { + return String.format("%s\t$%d\t%s", title(), price(), type()); + } +} diff --git a/tour-service/src/main/java/com/example/tourservice/TourType.java b/tour-service/src/main/java/com/example/tourservice/TourType.java new file mode 100644 index 0000000..c091b48 --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/TourType.java @@ -0,0 +1,15 @@ +package com.example.tourservice; + +/** + * A Classification of Tours. + * + * Created by Mary Ellen Bowman + */ +public enum TourType { + BACKPACKING, + CALM, + CYCLING, + KIDS, + NATURE; + +} diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java b/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java new file mode 100644 index 0000000..04334d1 --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java @@ -0,0 +1,22 @@ +package com.example.tourservice.utilities; + +import com.example.tourservice.Tour; +import com.example.tourservice.TourType; + +public class TourInitializer { + private TourRepository tourRepository; + public TourInitializer(TourRepository tourRepository) { + this.tourRepository = tourRepository; + tourRepository.save(new Tour("Big Sur Retreat", 750, TourType.BACKPACKING)); + tourRepository.save(new Tour("In the Steps of John Muir", 500, TourType.BACKPACKING)); + tourRepository.save(new Tour("The Death Valley Survivor's Trek", 200, TourType.BACKPACKING)); + tourRepository.save(new Tour( "Day Spa Package", 200, TourType.CALM)); + tourRepository.save(new Tour("Restoration Package", 350, TourType.CALM)); + tourRepository.save(new Tour("Monterey to Santa Barbara Tour", 550, TourType.CYCLING)); + tourRepository.save(new Tour( "Cycle California: My Way", 750, TourType.CYCLING)); + tourRepository.save(new Tour("Kids L.A. Tour", 100, TourType.KIDS)); + tourRepository.save(new Tour("Islands of the Blue Dolphins Tour", 200, TourType.KIDS)); + tourRepository.save(new Tour("Eco-Tour", 400, TourType.KIDS)); + tourRepository.save(new Tour("Endangered Species Expedition", 250, TourType.NATURE)); + } +} diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java b/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java new file mode 100644 index 0000000..b1088bc --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java @@ -0,0 +1,28 @@ +package com.example.tourservice.utilities; + +import java.util.*; + +import com.example.tourservice.Tour; +import com.example.tourservice.TourType; + +public class TourRepository { + private final List tours = new ArrayList<>(); + + public TourRepository() { + } + + public Tour save(Tour tour) { + if (!tours.contains(tour)) { + tours.add(tour); + } + return tour; + } + + public List findAll() { + return tours; + } + + public List findByCategory(TourType tc) { + return tours.stream().filter(t -> t.type().equals(tc)).toList(); + } +} diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java b/tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java new file mode 100644 index 0000000..101a202 --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java @@ -0,0 +1,12 @@ +package com.example.tourservice.utilities; + +public class TravelAgentService { + private TourRepository tourRepository; + + public TravelAgentService(TourRepository tourRepository) { + this.tourRepository = tourRepository; + } + public void display() { + tourRepository.findAll().stream().forEach(System.out::println); + } +} From 37e88b480e683f2e079b56b394ac09b8f19ea320 Mon Sep 17 00:00:00 2001 From: Mary Ellen Bowman Date: Mon, 1 Apr 2024 12:30:08 +0000 Subject: [PATCH 2/6] fat jar --- .vscode/settings.json | 3 ++- tour-service/pom.xml | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index a82add7..32344d6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,6 @@ "terminal.integrated.fontSize": 18, "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", - "workbench.statusBar.visible": true + "workbench.statusBar.visible": true, + "java.configuration.updateBuildConfiguration": "interactive" } \ No newline at end of file diff --git a/tour-service/pom.xml b/tour-service/pom.xml index 49127f4..8d3ccf8 100644 --- a/tour-service/pom.xml +++ b/tour-service/pom.xml @@ -13,4 +13,30 @@ 21 UTF-8 + + + + maven-assembly-plugin + + + package + + single + + + + + + + true + com.example.Application + + + + jar-with-dependencies + + + + + \ No newline at end of file From a69c98255577e0b6300170195c21d0a929d23905 Mon Sep 17 00:00:00 2001 From: Mary Ellen Bowman Date: Mon, 1 Apr 2024 12:37:30 +0000 Subject: [PATCH 3/6] move service --- tour-service/src/main/java/com/example/Application.java | 4 ++-- .../tourservice/{utilities => }/TravelAgentService.java | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) rename tour-service/src/main/java/com/example/tourservice/{utilities => }/TravelAgentService.java (68%) diff --git a/tour-service/src/main/java/com/example/Application.java b/tour-service/src/main/java/com/example/Application.java index 762a420..5071fd5 100644 --- a/tour-service/src/main/java/com/example/Application.java +++ b/tour-service/src/main/java/com/example/Application.java @@ -1,13 +1,13 @@ package com.example; +import com.example.tourservice.TravelAgentService; import com.example.tourservice.utilities.TourInitializer; import com.example.tourservice.utilities.TourRepository; -import com.example.tourservice.utilities.TravelAgentService; public class Application { public static void main(String[] args) { TourRepository tr = new TourRepository(); TourInitializer as = new TourInitializer(tr); TravelAgentService agentService = new TravelAgentService(tr); - agentService.display(); + agentService.displayTours(); } } \ No newline at end of file diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java b/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java similarity index 68% rename from tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java rename to tour-service/src/main/java/com/example/tourservice/TravelAgentService.java index 101a202..3941648 100644 --- a/tour-service/src/main/java/com/example/tourservice/utilities/TravelAgentService.java +++ b/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java @@ -1,4 +1,6 @@ -package com.example.tourservice.utilities; +package com.example.tourservice; + +import com.example.tourservice.utilities.TourRepository; public class TravelAgentService { private TourRepository tourRepository; @@ -6,7 +8,7 @@ public class TravelAgentService { public TravelAgentService(TourRepository tourRepository) { this.tourRepository = tourRepository; } - public void display() { + public void displayTours() { tourRepository.findAll().stream().forEach(System.out::println); } } From 8a1187f711883efcd0283d07c63c9ae06a82d00f Mon Sep 17 00:00:00 2001 From: Mary Ellen Bowman Date: Fri, 12 Apr 2024 15:10:38 +0000 Subject: [PATCH 4/6] Make it better --- .../main/java/com/example/Application.java | 19 +++++++++--- .../java/com/example/tourservice/Tour.java | 5 +-- .../tourservice/TourManagementService.java | 21 +++++++++++++ .../com/example/tourservice/TourType.java | 15 --------- .../tourservice/TravelAgentService.java | 8 ++++- .../utilities/TourInitializer.java | 22 ------------- .../tourservice/utilities/TourRepository.java | 31 +++++++++---------- 7 files changed, 60 insertions(+), 61 deletions(-) create mode 100644 tour-service/src/main/java/com/example/tourservice/TourManagementService.java delete mode 100644 tour-service/src/main/java/com/example/tourservice/TourType.java delete mode 100644 tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java diff --git a/tour-service/src/main/java/com/example/Application.java b/tour-service/src/main/java/com/example/Application.java index 5071fd5..0713f85 100644 --- a/tour-service/src/main/java/com/example/Application.java +++ b/tour-service/src/main/java/com/example/Application.java @@ -1,13 +1,22 @@ package com.example; + +import com.example.tourservice.TourManagementService; import com.example.tourservice.TravelAgentService; -import com.example.tourservice.utilities.TourInitializer; import com.example.tourservice.utilities.TourRepository; public class Application { public static void main(String[] args) { - TourRepository tr = new TourRepository(); - TourInitializer as = new TourInitializer(tr); - TravelAgentService agentService = new TravelAgentService(tr); - agentService.displayTours(); + // Must create Repo First + TourRepository repo = new TourRepository(); + TravelAgentService agent = new TravelAgentService(repo); + + new TourManagementService(repo); //Creates tours in constructor + + // Do not invoke agent method before manager creates base tours + System.out.println("\n******Explore California Tour Catalogue******"); + agent.displayTours(); + + System.out.println("\n******Explore California Tour Kid Friendly Tours******"); + agent.displayToursBy(true); } } \ No newline at end of file diff --git a/tour-service/src/main/java/com/example/tourservice/Tour.java b/tour-service/src/main/java/com/example/tourservice/Tour.java index 71460f7..5f6046f 100644 --- a/tour-service/src/main/java/com/example/tourservice/Tour.java +++ b/tour-service/src/main/java/com/example/tourservice/Tour.java @@ -5,9 +5,10 @@ * * Created by Mary Ellen Bowman */ -public record Tour(String title, Integer price, TourType type) { +public record Tour(String title, Integer price, Boolean kidFriendly) { @Override public String toString() { - return String.format("%s\t$%d\t%s", title(), price(), type()); + return String.format("%s\t$%d\tKid Friendly: %s", + title(), price(), kidFriendly ? "Yes" : "No"); } } diff --git a/tour-service/src/main/java/com/example/tourservice/TourManagementService.java b/tour-service/src/main/java/com/example/tourservice/TourManagementService.java new file mode 100644 index 0000000..57fd9e9 --- /dev/null +++ b/tour-service/src/main/java/com/example/tourservice/TourManagementService.java @@ -0,0 +1,21 @@ +package com.example.tourservice; + +import com.example.tourservice.utilities.TourRepository; + +public class TourManagementService { + private TourRepository tourRepository; + + public TourManagementService(TourRepository tourRepository) { + this.tourRepository = tourRepository; + createTour("Big Sur Retreat", 750, true); + createTour( "Day Spa Package", 200, false); + createTour("Monterey to Santa Barbara Tour", 550, false); + createTour("Kids L.A. Tour", 100, true); + createTour("Islands of the Blue Dolphins Tour", 200, true); + createTour("Endangered Species Expedition", 250, true); + } + + public Tour createTour(String title, Integer price, Boolean isKidFriendly) { + return tourRepository.save(new Tour(title, price, isKidFriendly)); + } +} diff --git a/tour-service/src/main/java/com/example/tourservice/TourType.java b/tour-service/src/main/java/com/example/tourservice/TourType.java deleted file mode 100644 index c091b48..0000000 --- a/tour-service/src/main/java/com/example/tourservice/TourType.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.example.tourservice; - -/** - * A Classification of Tours. - * - * Created by Mary Ellen Bowman - */ -public enum TourType { - BACKPACKING, - CALM, - CYCLING, - KIDS, - NATURE; - -} diff --git a/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java b/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java index 3941648..b62a85e 100644 --- a/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java +++ b/tour-service/src/main/java/com/example/tourservice/TravelAgentService.java @@ -3,12 +3,18 @@ import com.example.tourservice.utilities.TourRepository; public class TravelAgentService { - private TourRepository tourRepository; + private TourRepository tourRepository; public TravelAgentService(TourRepository tourRepository) { this.tourRepository = tourRepository; } + public void displayTours() { tourRepository.findAll().stream().forEach(System.out::println); } + + public void displayToursBy(Boolean isKidFriendly) { + tourRepository.findByType(isKidFriendly).stream() + .forEach(System.out::println); + } } diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java b/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java deleted file mode 100644 index 04334d1..0000000 --- a/tour-service/src/main/java/com/example/tourservice/utilities/TourInitializer.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.example.tourservice.utilities; - -import com.example.tourservice.Tour; -import com.example.tourservice.TourType; - -public class TourInitializer { - private TourRepository tourRepository; - public TourInitializer(TourRepository tourRepository) { - this.tourRepository = tourRepository; - tourRepository.save(new Tour("Big Sur Retreat", 750, TourType.BACKPACKING)); - tourRepository.save(new Tour("In the Steps of John Muir", 500, TourType.BACKPACKING)); - tourRepository.save(new Tour("The Death Valley Survivor's Trek", 200, TourType.BACKPACKING)); - tourRepository.save(new Tour( "Day Spa Package", 200, TourType.CALM)); - tourRepository.save(new Tour("Restoration Package", 350, TourType.CALM)); - tourRepository.save(new Tour("Monterey to Santa Barbara Tour", 550, TourType.CYCLING)); - tourRepository.save(new Tour( "Cycle California: My Way", 750, TourType.CYCLING)); - tourRepository.save(new Tour("Kids L.A. Tour", 100, TourType.KIDS)); - tourRepository.save(new Tour("Islands of the Blue Dolphins Tour", 200, TourType.KIDS)); - tourRepository.save(new Tour("Eco-Tour", 400, TourType.KIDS)); - tourRepository.save(new Tour("Endangered Species Expedition", 250, TourType.NATURE)); - } -} diff --git a/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java b/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java index b1088bc..6046888 100644 --- a/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java +++ b/tour-service/src/main/java/com/example/tourservice/utilities/TourRepository.java @@ -3,26 +3,25 @@ import java.util.*; import com.example.tourservice.Tour; -import com.example.tourservice.TourType; public class TourRepository { - private final List tours = new ArrayList<>(); + private final List tours = new ArrayList<>(); - public TourRepository() { - } + public TourRepository() { + } - public Tour save(Tour tour) { - if (!tours.contains(tour)) { - tours.add(tour); - } - return tour; - } + public Tour save(Tour tour) { + if (!tours.contains(tour)) { + tours.add(tour); + } + return tour; + } - public List findAll() { - return tours; - } + public List findAll() { + return tours; + } - public List findByCategory(TourType tc) { - return tours.stream().filter(t -> t.type().equals(tc)).toList(); - } + public List findByType(Boolean isKidFriendly) { + return tours.stream().filter(t -> t.kidFriendly() == isKidFriendly).toList(); + } } From 0207fff87d266f2193b2d23175f85a3f509e9ba5 Mon Sep 17 00:00:00 2001 From: Mary Ellen Bowman Date: Mon, 22 Apr 2024 17:57:30 +0000 Subject: [PATCH 5/6] popup --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 32344d6..54e3ec0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -20,5 +20,5 @@ "workbench.colorTheme": "Visual Studio Dark", "workbench.fontAliasing": "antialiased", "workbench.statusBar.visible": true, - "java.configuration.updateBuildConfiguration": "interactive" + "java.configuration.updateBuildConfiguration": "disabled" } \ No newline at end of file From a3d988a46832524803414d6304308312a7ece1fa Mon Sep 17 00:00:00 2001 From: smoser-LiL Date: Mon, 17 Jun 2024 17:36:10 +0000 Subject: [PATCH 6/6] Moving files using main --- NOTICE | 5 +---- README.md | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/NOTICE b/NOTICE index 547595f..2809d69 100644 --- a/NOTICE +++ b/NOTICE @@ -1,12 +1,9 @@ -Copyright 2022 LinkedIn Corporation +Copyright 2024 LinkedIn Corporation All Rights Reserved. Licensed under the LinkedIn Learning Exercise File License (the "License"). See LICENSE in the project root for license information. -ATTRIBUTIONS: -[PLEASE PROVIDE ATTRIBUTIONS OR DELETE THIS AND THE ABOVE LINE “ATTRIBUTIONS”] - Please note, this project may automatically load third party code from external repositories (for example, NPM modules, Composer packages, or other dependencies). If so, such third party code may be subject to other license terms than as set diff --git a/README.md b/README.md index 4d73c8c..5b2f20c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Creating Spring Boot Microservices This is the repository for the LinkedIn Learning course Creating Spring Boot Microservices. The full course is available from [LinkedIn Learning][lil-course-url]. -![course-name-alt-text][lil-thumbnail-url] +![lil-thumbnail-url] + +

If you’re looking for a practical introduction on creating Spring Boot microservices, this course was designed just for you. Join instructor and software developer Mary Ellen Bowman as she provides a skills-based, intermediate-level overview on how to create microservices using the power of Spring Boot 3. Along the way, discover several other related technologies and frameworks such as Spring Data, Spring Data REST, Spring MVC, JUnit, Mockito, SpringBootTest, Docker, MongoDB, Spring Security, and Spring Cloud.

This course is integrated with GitHub Codespaces, an instant cloud developer environment that offers all the functionality of your favorite IDE without the need for any local machine setup. With GitHub Codespaces, you can get hands-on practice from any machine, at any time-all while using a tool that you'll likely encounter in the workplace. Check out the "Using GitHub Codespaces with this course" video to learn how to get started.

_See the readme file in the main branch for updated instructions and information._ ## Instructions @@ -22,15 +24,19 @@ To resolve this issue: Add changes to git using this command: git add . Commit changes using this command: git commit -m "some message" -## Installing -1. To use these exercise files, you must have the following installed: - - [list of requirements for course] -2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. -3. [Course-specific instructions] + ### Instructor + +Mary Ellen Bowman +25+ years of full life-cycle software development experience + + + +Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/mary-ellen-bowman?u=104). + [0]: # (Replace these placeholder URLs with actual course URLs) -[lil-course-url]: https://www.linkedin.com/learning/ -[lil-thumbnail-url]: http:// +[lil-course-url]: https://www.linkedin.com/learning/creating-spring-boot-microservices +[lil-thumbnail-url]: https://media.licdn.com/dms/image/D560DAQGP3Ee7Z9yRyA/learning-public-crop_675_1200/0/1717532201518?e=2147483647&v=beta&t=WIL8JOcMr2LPb7eXi0pmZ3qXoxRTvso6V-sQfHIpV-I