I’ve a simple POST API where the @RequestBody contains a variable of type HashMap. The problem is that the variable “myMap” is never populated. Swagger UI shows the entry field correctly, with corresponding default values. I also added the a static block in the Configuration file, otherwise …
Tag: spring-boot
Can’t use any kind of SessionListener when using Spring Security in Spring Boot
I have a very basic Spring Security setup using Session. My problem is that I can’t find a way to use any kind of Session Listener (both Spring and Servlet API versions) to listen to SessionCreated event. Login is working and session is being created properly. The reason I need a listener is because I w…
Casting a string to an integer and then to a double – how to retrieve up to four positions behind the decimal position in a correct way?
I am currently working on a simple BMI (Body Mass Index) calculator in Java, in a larger Java / Spring Boot application with Mojito Tests. My function uses height and weight as Input values to calculate the BMI. Through the arithmetic operations, the received Input values – Strings, casted to Integers &…
Compare Map Value with list using Stream API
Need to collect the common value from a List of String and from a MAP having String as KEY and List as VALUE. Snippet: In third method need to compare the List and MAP value and collect the common no in a List. Please guide using JAVA 8 Stream API Answer
Ktorm entities as springboot controller parameters
I’m trying to use Ktorm in my new springboot application, and get myself into problem when trying to use Ktorm entities interfaces as springboot controller parameters. The entity and Controller look like this: I got this exception once calling function addTask(): [HttpMessageConversionException] Type de…
How to design two seperate authorization/authentication configurations in spring boot?
I want to implement authentication and authorization for spring boot application with this design: First group of endpoints (“/api/**) will have authorization by passing the api-secret-key through requests headers. Authentication should be permitted for all. Second group (/admin/**) will have authentica…
Having problems trying to test functionality that contains autowired SprngBoot with junit 5
I want to test some functinality, a service with a repo that is autowired in. I dont want to mock the autowired, this is more a integration test for debugging. My test is as follow The code is very simple The problem is that throttleRateRepository is always null. I have managed to test this sort of code befor…
Use a secondary h2 database for testing an API in Spring boot
I’m developing an API to manage a database in the company where I work, the problem is that when I have to run the different test I have to use the “real” dev database (in h2) where I have some real data. I thought about it and what I wanted to do is create a new h2 database that could
IllegalArgumentException at MetamodelImpl.java gradle build error
I keep on getting a IllegalArgumentException at MetamodelImpl.java and I am not sure what is causing it. I pulled a brand new Spring project from start spring io just with basic Web, Lombok and JPA dependencies. I tried building it with gradle doing ./gradlew clean build and it keep throwing this error. Here …
set Content-Type to application/Json using Fetch API javascript
I am trying to send some form data to a spring application using Fetch API in javascript. I have this code to send the form data: but i get a 415 status error “Unsupported Media Type”. Even when i set specifically the header ‘Content-Type’ to ‘application/json’ it sends lik…