Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
node_modules
.tmp
npm-debug.log
*.class
*.jar
tour-service/target
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
5 changes: 1 addition & 4 deletions NOTICE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 14 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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]

<p>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.</p><p>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.</p>

_See the readme file in the main branch for updated instructions and information._
## Instructions
Expand All @@ -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

50 changes: 50 additions & 0 deletions tour-service/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>tour-service</artifactId>
<version>1.0.0</version>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.0</version> <!-- Or the latest version -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.example.Application</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>

</project>
29 changes: 29 additions & 0 deletions tour-service/src/main/java/com/example/Application.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.example;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.example.tourservice.TourManagementService;
import com.example.tourservice.TravelAgentService;
import com.example.tourservice.utilities.TourRepository;

public class Application {

public static void main(String[] args) {

ApplicationContext context = new AnnotationConfigApplicationContext(Application.class.getPackageName());
TravelAgentService agent = context.getBean(TravelAgentService.class);

// create a tour
// invoke TourManagementService.createTour()
// title: "Zoo Tour"; Price: 100; Kid Friendly = true
TourManagementService tourMgntSvc = context.getBean(TourManagementService.class);
tourMgntSvc.createTour("Zoo Tour", 100, true);

System.out.println("\n******Explore California Tour Catalogue******");
agent.displayTours();

System.out.println("\n******Explore California Tour Kid Friendly Tours******");
agent.displayToursBy(true);
}
}
14 changes: 14 additions & 0 deletions tour-service/src/main/java/com/example/tourservice/Tour.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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, Boolean kidFriendly) {
@Override
public String toString() {
return String.format("%s\t$%d\tKid Friendly: %s",
title(), price(), kidFriendly ? "Yes" : "No");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.tourservice;

import org.springframework.stereotype.Service;

import com.example.tourservice.utilities.TourRepository;

@Service
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 SantaBarbara Tour", 550, false);
createTour("Kids L.A. Tour", 100, true);
createTour("Islands of the Blue Dolphins Tour", 200, true);
createTour("Endangered Specie Expedition", 250, true);
}

public Tour createTour(String title, Integer price, Boolean isKidFriendly) {
return tourRepository.save(new Tour(title, price, isKidFriendly));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.example.tourservice;

import org.springframework.stereotype.Service;

import com.example.tourservice.utilities.TourRepository;

@Service
public class TravelAgentService {
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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.example.tourservice.utilities;

import java.util.*;

import org.springframework.stereotype.Repository;

import com.example.tourservice.Tour;

@Repository
public class TourRepository {
private final List<Tour> tours = new ArrayList<>();

public TourRepository() {
}

public Tour save(Tour tour) {
if (!tours.contains(tour)) {
tours.add(tour);
}
return tour;
}

public List<Tour> findAll() {
return tours;
}

public List<Tour> findByType(Boolean isKidFriendly) {
return tours.stream().filter(t -> t.kidFriendly() == isKidFriendly).toList();
}
}