Skip to content

Instantly share code, notes, and snippets.

View TestUserService.java
public class TestUserService {
@Test
public void testFindUserExisting() {
Map<Long, User> users = new HashMap<>();
users.put(100L, new User(100L, "John", "Doe"));
UserService service = new UserService(users, null);
User returnedUser = service.findUser(100L);
View ConstructorInjection.java
public class UserController {
private UserService service;
public UserController(UserService service) {
this.service = service;
}
...
}
View ExceptionHandler.java
@ExceptionHandler(ClientException.class)
public ResponseEntity<String> clientError(ClientException e) {
return ResponseEntity.badRequest().body(e.getMessage());
}
@ExceptionHandler(NotFoundException.class)
public ResponseEntity<String> resourceNotFound(NotFoundException e) {
return ResponseEntity.notFound().build();
}
View UserService.java
@Service
public class UserService {
private List<User> users = new ArrayList<>();
private static final Random ID_GENERATOR = new Random();
public User findUser(long userId) {
for(User user : users) {
if(user.getId().equals(Long.valueOf(userId))) {
return user;
View UserController.java
@RestController
@RequestMapping("/api/v1/users")
public class UserController {
private UserService service;
public UserController(UserService service) {
this.service = service;
}
View HeaderParam.java
@GetMapping("/header")
public String welcomeUser(@RequestHeader String user) {
return String.format("Welcome %s!", user);
}
View RequestParam.java
@GetMapping("/name")
public String helloQueryMessage(@RequestParam String firstName, @RequestParam String lastName) {
return String.format("Hello %s %s!", firstName, lastName);
}
View spring-boot-devtools.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
View PathVariable.java
@GetMapping("/{message}")
public String helloMessage(@PathVariable String message) {
return String.format("Hello, %s!", message);
}
View README.md

Extending Spring Boot for the Enterprise and Cloud Workshop

Spring Boot has become incredibly popular since it's initial release in 2013. Spring Boot allows developers in the matters of minutes or hours to build functionality that would take days or weeks to build before.

Over the same time period Cloud Platforms have grown in size and capability. Like Spring Boot Cloud platforms can deliver functionality in minutes or hours what would take many organizations days, weeks, or even months to build out and deploy.

While this "out of the box" functionality of Spring Boot and Cloud platforms is great, it can be taken further. Spring Boot and Cloud Platforms are built to address very broad domains, but individual organizations will often have a much more narrow focus. In this workshop we will see how we can extend and build on top of Spring Boot and Cloud platforms to better address the needs of our organizations.

What You Will Learn

In this workshop you will learn about the following concepts: