PacktPublishing / Learning-Spring-Boot-3.0-Third-Edition

Learning Spring Boot 3.0, published by Packt
MIT License
155 stars 118 forks source link

Learning Spring Boot 3.0

This is the code repository for Learning Spring Boot 3.0, published by Packt.

Simplify the development of production-grade applications using Java and Spring

What is this book about?

Spring Boot 3 brings more than just the powerful ability to build secure web apps on top of a rock-solid database. It delivers new options for testing, deployment, Docker support, and native images for GraalVM, along with ways to squeeze out more efficient usage of existing resources.

This book covers the following exciting features:

If you feel this book is for you, get your copy today!

<img src="https://raw.githubusercontent.com/PacktPublishing/GitHub/master/GitHub.png" alt="https://www.packtpub.com/" border="5" />

Instructions and Navigations

All of the code is organized into folders. For example, Ch2.

The code will look like the following:

@Controller
public class HomeController {
  private final VideoService videoService;
  public HomeController(VideoService videoService) {
    this.videoService = videoService;
  }

  @GetMapping("/")
  public String index(Model model) {
    model.addAttribute("videos", videoService.getVideos());
    return "index";
  }
}

Following is what you need for this book: This book is for both novices and experienced Spring developers looking to learn how to build applications without wasting time on infrastructure and other tedious details. Working knowledge of the Java programming language is assumed.

With the following software and hardware list you can run all code files present in the book (Chapter 1-10).

Software and Hardware List

Chapter Software required OS required
1-10 sdkman (for Java 17) (https://sdkman.io) Windows, Mac OS X, and Linux (Any)
1-10 IntelliJ IDEA (https://springbootlearning.com/intellij-idea) Windows, Mac OS X, and Linux (Any)
1-10 VS Code (https://springbootlearning.com/) Windows, Mac OS X, and Linux (Any)
1-10 Spring Tool Suite (https://springbootlearning.com/sts) Windows, Mac OS X, and Linux (Any)

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.

Related products

Errata

Original Code Snippet (Pages 108-109):

@Configuration
public class YouTubeConfig {

  static String YOUTUBE_V3_API = //
    "https://www.googleapis.com/youtube/v3";

  @Bean
  WebClient webClient( //
    OAuth2AuthorizedClientManager clientManager) {

    ServletOAuth2AuthorizedClientExchangeFilterFunction oauth2 = //
      new ServletOAuth2AuthorizedClientExchangeFilterFunction( //
        clientManager);
    oauth2.setDefaultClientRegistrationId("google");

    return WebClient.builder() //
      .baseUrl(YOUTUBE_V3_API) //
      .apply(oauth2.oauth2Configuration()) //
      .build();
  }
}

Missing Code Snippet:

@Bean
HttpServiceProxyFactory proxyFactory(WebClient oauth2WebClient) {
  return HttpServiceProxyFactory.builder() //
    .clientAdapter(WebClientAdapter.forClient(oauth2WebClient)) //
    .build();
}

@Bean
YouTube client(HttpServiceProxyFactory factory) {
  return factory.createClient(YouTube.class);
}

Updated Code Snippet (Including Missing Code):

@Configuration
public class YouTubeConfig {

  static String YOUTUBE_V3_API = //
    "https://www.googleapis.com/youtube/v3";

  @Bean
  WebClient webClient( //
    OAuth2AuthorizedClientManager clientManager) {

    ServletOAuth2AuthorizedClientExchangeFilterFunction oauth2 = //
      new ServletOAuth2AuthorizedClientExchangeFilterFunction( //
        clientManager);
    oauth2.setDefaultClientRegistrationId("google");

    return WebClient.builder() //
      .baseUrl(YOUTUBE_V3_API) //
      .apply(oauth2.oauth2Configuration()) //
      .build();
  }

  @Bean
  HttpServiceProxyFactory proxyFactory(WebClient oauth2WebClient) {
    return HttpServiceProxyFactory.builder() //
      .clientAdapter(WebClientAdapter.forClient(oauth2WebClient)) //
      .build();
  }

  @Bean
  YouTube client(HttpServiceProxyFactory factory) {
    return factory.createClient(YouTube.class);
  }
}

Please update the YouTubeConfig.java file with the above complete code snippet to ensure completeness in configuring the HTTP service proxy and creating the YouTube client.

Get to Know the Author

Greg L. Turnquist is a senior staff technical content engineer at Cockroach Labs and was a former developer on the Spring team. He was the project lead for Spring Data JPA and has committed to multiple projects including Spring Boot, Spring Security, R2DBC, Spring HATEOAS, and more. He has written the Hacking with Spring Boot series as well as Packt's best-selling title, Learning Spring Boot 2.0 2nd Edition. He co-founded the Nashville Java User Group in 2010 and hasn't met a Java app (yet) that he doesn't like.

He completed his master's degree in computer engineering at Auburn University and lives in the United States with his family.

Be sure to check out his YouTube channel, Pro Coder, where you learn to become a savvy pro!

Download a free PDF

If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.

https://packt.link/free-ebook/9781803233307