Coder Social home page Coder Social logo

repo's Introduction

Spring Boot in Practice

The book cover of 'Spring Boot in Practice' by Somnath Musib

Spring Boot in Practice is a Spring Boot book written by Somnath Musib and published by Manning Publications. It's currently available through the Manning Early Access Program (MEAP). This book covers dozens of handy Spring Boot development techniques, from basic functions to hidden features you probably didn’t even know existed. Each recipe is built around a real-world problem and shows you how Spring Boot can provide a simple and elegant solution.

This repository contains the source code accompanying the book.

What will you learn?

In Spring Boot in Practice you will learn:

  • A comprehensive introduction to Spring Boot’s features
  • Configuration management, logging, and monitoring Spring Boot applications
  • Effective methods for database communication
  • Utilizing Spring Security and securing your Spring application in production
  • Designing and developing microservices and RESTful APIs with Spring Boot
  • Microservice versioning, documentation, and security
  • Reactive application development and reactive data access with WebSocket and RSocket
  • Deploying Spring Boot applications on Kubernetes and major cloud platforms
  • Implementing containerization in a Spring Boot application
  • Using Spring Boot with Kotlin, GraalVM and GraphQL

Spring Boot in Practice is full of practical recipes for troubleshooting common development problems with Spring Boot. I have spent years building applications with Spring and share my extensive experience in this focused guide. You’ll master Spring Data, Spring Security, and other Spring-centric solutions for the common business problems you face every day as a software developer.

Gradle and Maven

The code samples in the book use Apache Maven as the build tool. If you prefer Gradle over Maven, here's a table mapping Maven commands to Gradle:

Maven Gradle
./mvnw clean ./gradlew clean
./mvnw install ./gradlew build
./mvnw test ./gradlew test
./mvnw repackage ./gradlew bootJar
./mvnw spring-boot:run ./gradlew bootRun
./mvnw spring-boot:build-image ./gradlew bootBuildImage

Chapters

  • Chapter 01 Booting Spring Boot
  • Chapter 02 Spring Boot Common Tasks
  • Chapter 03 Database Access with Spring Data
  • Chapter 04 Spring Boot - Autoconfiguration and Actuator
  • Chapter 05 Securing Spring Boot Applications
  • Chapter 06 Implementing Additional Security with Spring Security
  • Chapter 07 Developing RESTful Web Services with Spring Boot
  • Chapter 08 Reactive Spring Boot Application Development
  • Chapter 09 Deploying Spring Boot Applications
  • Chapter 10 Spring Boot with Kotlin, Native Image and GraphQL
  • Appendix A Generating and Building Spring Boot projects
  • Appendix B Spring MVC and Thymeleaf Template Engine

Book forum

Feel free to submit questions, feedback, or errata to the forum dedicated to "Spring Boot in Practice": https://livebook.manning.com/book/spring-boot-in-practice/.

Contact the author

You are always welcome to contact me for questions, feedback, or suggestions. Feel free to reach out to me on Twitter, LinkedIn, or here on GitHub.

repo's People

Contributors

musibs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

repo's Issues

Chapter 3 CrudRepository Tests Fail.

(repo/ch03/manage-domain-objects-with-jpa/course-tracker-final/)

My code matches your GitHub code except I'm updating the source that I started with in chapter 1. As a result you'll see ch01 instead of ch03 in the path. Everything compiles, but the tests fail. My Test has:

    @Autowired
    private CourseRepository courseRepository;

My CourseRepository matches your GitHub code (only a @repository annotation).

package com.manning.sbip.ch01.repository;

import com.manning.sbip.ch01.model.Course;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface CourseRepository extends CrudRepository<Course, Long> {
}

I also updated Course to match the JPA changes provided in the GitHub repository.

At the start of the test output, I see (notice no JPA repository interfaces are found):

2021-07-24 13:12:29.041 [ INFO] [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 21 ms. Found 0 JPA repository interfaces.

I also tried updating SpringBootAppDemoApplicationTests with Autowired required=true, but it did not help.

@Autowired(required=true)
private CourseRepository courseRepository;
2021-07-24 12:39:51.334 [ERROR] [           main] o.s.t.c.TestContextManager               : Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@10e4cc6] to prepare test instance [com.manning.sbip.ch01.springbootappdemo.SpringBootAppDemoApplicationTests@1e203e6]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.manning.sbip.ch01.springbootappdemo.SpringBootAppDemoApplicationTests': Unsatisfied dependency expressed through field 'courseRepository'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.manning.sbip.ch01.repository.CourseRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

I checked for obvious package name problems, but the source matches yours except for the ch01 references. There are no compile issues.

Running the app using mvn spring-boot:run is successful, but the same Found 0 JPA repository interfaces message is displayed.

I am running on Linux and using PostgreSQL instead of H2, but I would not think either would cause this problem. The previous relational tests worked fine. It's just this switch to JPA that caused the issue.

Circular reference issue when running the example in Chapter 06

When I am trying to run the course-tracker-remember-me-final project associated with Chapter 06, I am getting Circular Reference errors.

APPLICATION FAILED TO START


Description:

The dependencies of some of the beans in the application context form a cycle:

emailVerificationController (field private com.manning.sbip.ch06.service.UserService com.manning.sbip.ch06.controller.EmailVerificationController.userService)
┌─────┐
| defaultUserService (field private org.springframework.security.crypto.password.PasswordEncoder com.manning.sbip.ch06.service.impl.DefaultUserService.passwordEncoder)
↑ ↓
| securityConfiguration (field private com.manning.sbip.ch06.service.impl.CustomUserDetailsService com.manning.sbip.ch06.security.SecurityConfiguration.customUserDetailsService)
↑ ↓
| customUserDetailsService (field private com.manning.sbip.ch06.service.UserService com.manning.sbip.ch06.service.impl.CustomUserDetailsService.userService)
└─────┘

Action:

Relying upon circular references is discouraged and they are prohibited by default. Update your application to remove the dependency cycle between beans. As a last resort, it may be possible to break the cycle automatically by setting spring.main.allow-circular-references to true.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.