Spring Boot Microservices – Spring Security – ServiceTest and ControllerTest for JUnit throwing java.lang.StackOverflowError

The error is most likely caused by declaring the AuthenticationManager as a @Bean. Try this in your test class: @MockBean private AuthenticationManager _authenticationManager; That said, the Spring Security team does not recommend exposing the AuthenticationManager in this way, see the comment in Spring issue #29215

bootstrap.yml configuration not processed anymore with Spring Cloud 2020.0

As pointed put by Nicoll, With Spring Cloud Vault 3.0 and Spring Boot 2.4, the bootstrap context initialization (bootstrap.yml, bootstrap.properties) of property sources was deprecated. This can be fixed in one of the 2 ways Use Spring Boot 2.4.0 Config Data API to import configuration from Vault (Preferred) Legacy Processing: Enable the bootstrap context either … Read more

Customizing Zuul Exception

We finally got this working [Coded by one of my colleague]:- public class CustomErrorFilter extends ZuulFilter { private static final Logger LOG = LoggerFactory.getLogger(CustomErrorFilter.class); @Override public String filterType() { return “post”; } @Override public int filterOrder() { return -1; // Needs to run before SendErrorFilter which has filterOrder == 0 } @Override public boolean shouldFilter() … Read more

How to get custom user info from OAuth2 authorization server /user endpoint

The solution is the implementation of a custom UserInfoTokenServices https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java Just Provide your custom implementation as a Bean and it will be used instead of the default one. Inside this UserInfoTokenServices you can build the principal like you want to. This UserInfoTokenServices is used to extract the UserDetails out of the response of the /usersendpoint … Read more

Understanding Spring Cloud Eureka Server self preservation and renew threshold

I got the same question as @codependent met, I googled a lot and did some experiment, here I come to contribute some knowledge about how Eureka server and instance work. Every instance needs to renew its lease to Eureka Server with frequency of one time per 30 seconds, which can be define in eureka.instance.leaseRenewalIntervalInSeconds. Renews … Read more

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

I have just asked the Spring Cloud guys and thought I should share the info I have here. bootstrap.yml is loaded before application.yml. It is typically used for the following: when using Spring Cloud Config Server, you should specify spring.application.name and spring.cloud.config.server.git.uri inside bootstrap.yml some encryption/decryption information Technically, bootstrap.yml is loaded by a parent Spring … Read more