Skip to content

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

Repository files navigation

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:

  • Create powerful, production-grade web applications with minimal fuss
  • Support multiple environments with one artifact, and add production-grade support with features
  • Find out how to tweak your Java apps through different properties
  • Enhance the security model of your apps
  • Make use of enhancing features such as native deployment and reactive programming in Spring Boot
  • Build anything from lightweight unit tests to fully running embedded web container integration tests
  • Get a glimpse of reactive programming and decide if it's the right approach for you

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

https://www.packtpub.com/

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

  • Page 65, Note box: !!putting the wildcard at the beginning!! should be !!putting the wildcard at the END!!
  • Page 65, Note box: EndsWith puts the wildcard at the end should be EndsWith puts the wildcard at the beginning
  • In Chapter 4, under the section "Invoking an OAuth2 API remotely," there is a missing code snippet after the provided snippet on pages 108-109.

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

About

Learning Spring Boot 3.0, published by Packt

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •