The coach object is created with Annotations and coach2 is created with XML configuration file. They both refering to the tennisCoach class. In singleton scope beans refer to the same place in memory but in this situation memory place is different. I have two questions. Why Spring lets us create two objects? Why it doesn’t give an error about why
Tag: spring
Spring Boot Unit Test returns 404 instead of 200
I am new in springboot. I am just watching the Spring in Action and programming follow the author. then things get difficult when i just reading the chapter 1. I need to test a controller. the code in this book is: I am using springboot 2.7.3 so i just remove @RunWith(SpringRunner.class) from my code. and i immediately get an error
What are the best practices for calculating statistics in REST API applications
I am trying to make a service that will calculate statistics for each month. I did smth like this: But it takes a long time if there are lots of etries in the database. Are there any best practices for working with statistics in REST API applications? And also I’d like to know if it is a good way to
Spring Boot, Spring-Security – BcrypPasswordEncoder in new component-based security configuration
I am trying to use the new Component-Based (Without WebSecurityConfigurerAdapter) configuration and setted up my Security Configuration as follow: SecurityConfiguration.java file but when I run the application and try to log a user the following error appears even though I have the BCryptPasswordEncoder as a bean in my SecurityConfiguration: Error Stack Trace* Which is the correct way to set up
@DeleteMapping endpoint not triggered at all
My webClient calls work fine with @GetMapping, but @DeleteMapping isn’t even triggered. Here are the two methods I’m using: The endpoints are: When I try to delete an item I get no errors, no 405, no 400, no 403, nothing. The webClient call returns normally (with a MonoIgnorePublisher object), but the endpoint seems to not be triggered at all (I
Spring-Boot When running .JAR of project it fails to initialize JPA
What I want to achieve is that when I push something to my staging branch on github a script on the Ubuntu server automatically pulls the branch, compiles the project and runs the .JAR file. But I’m facing a problem where if I package my project on Ubuntu it fails to initialize JPA EntityManagerFactory. It gives the following exception: “Failed
SecurityFilterChain Bean doesn’t protect app
I am in the middle of process of mirgation my Spring Security Configuration from WebSecurityConfigurerAdapter (deprecated) to configuration with beans. My config class now looks like I understand that this configuration doesn’t make any behavior settings, but shouldn’t it return a SecurityFilterChain bean that will act like the default SecurityFilterChain (as if no configuration was specified)? When I start my
Spring RestTemplate: how to send the payload body as compact form so without rn
I am dealing with an API that don’t accept multi line json body and accept only 1 json line body (json compact form) The below payload is valid because it’s compact in just 1 line And the below payload is not passing because it’s multiline I have the same problem in the Java/Spring code where I got this error while
Spring @PostMapping force null values for formdata urlencode?
When I run the following request, the values in my received object are not null, but “” empty: Question: how can I tell Spring to not add empty values on Strings, but keep them null? Answer Could solve it as follows: This converts any empty strings to nulls.
Spring retry – Thread interruption handling
I am using spring-retry v1.3.1 with @Retryable annotation and I have a few questions on its behaviour. Let’s say that in my spring boot application I have a retry configuration that makes my application wait 1 hour before retrying. If my application is killed (for example by kubernetes) while it was waiting in order to do a retry is there