I need to run a Spring Boot app using different configuration files. In local I can do it with the following JVM Option: What’s the way to do this when I run the app from a Jenkins job? Answer With the assumption that user knows .jenkins file, I provide below the code snippet. For more details and reference, check below
Tag: spring-boot
Dynamically add property sources to SpringBootTest
Similar to Springboot unit test set @Configuration Properties dynamically but the context is different. In my case I have a TestContainer running a custom MySQL database that is prepopulated with a …
JSON Custom response in all my REST API, I might not know what it is called?
So the problem goes like this, for all my REST API endpoints there should be 3 fields always there in my RESPONSE Body like for eg: or So you can get the idea, I want this message status error or data field to be there in all response in my REST API. Answer It could be achieved with a ResponseBodyAdvice:
Attribute ServerContainer not found in ServletContext
In my Spring boot application i use also websockets. Everything works fine, as expected in production. Now i started to create UnitTests with Spring-Boot-Test. Every time i start a @SpringBootTest , i get following exception (shortened): Long Version Spring Websocket Config Class POM.XML Spring Application Class Typical Failing Test Problem The Problem is, the actual Test never comes to the
Spring Boot graceful shutdown
I am developing a Spring Boot application backed by embedded Tomcat and I need to develop a graceful shutdown with the following steps: stop processing new HTTP requests (stop web container) process all already accepted requests shutdown Spring ApplicationContext *do the steps above sequentially (one by one) How can I achieve this? P.S. Spring Boot 1.5.20.RELEASE, Java 8 Answer I
Route order in Spring Cloud Gateway
We are implementing routes programmatically using a implementation of RouteDefinitionLocator. We have two services which should register at the same route path, where one of them is meant as a fallback if the other one does not exist. The preferred route with the specific path is: And the more general one, which should only fire if other route was found:
Making multiple requests with Spring WebClient
So my goal is to use WebClient to make multiple concurrent requests, wait until they’re all completed, then combine the results. Here is what I have so far: Basically my goal is to combine all the items from each of the feeds to create one unified feed. However, I am not quite sure what to do after the call to
Spring Security returns 404 instead of 403 when using @PreAuthorize
After struggling with this for a few days (searching SO for similar questions, doing trial & error), I am tempted to give up… So the problem is I have a REST service based on Spring Boot using Spring Security and JWT for authentication. Now I want to secure some of the methods to be only called by authorized people using
How to disable Google Cloud Platform integration?
I have these two dependencies in my POM file: I’d like to disable these GCP features in certain profiles. I need to test my app locally but GCP keeps getting in the way. Answer Spring depends on auto-configuration when setting up the application. In many cases, it scans the classpath for certain dependencies, and if they are present, auto-configuration is
flyway schema giving IllegalArgumentException
On running flyway schema I’m receiving this exception.using Java 8 with spring boot. Flyway is not able to initialize. org.springframework.beans.factory.BeanCreationException: Error creating bean …