In my spring boot web application, I want to serialize many different classes to JSON when I return them from the function of a request mapping. These classes only contain private fields without getters. In order for Jackson to serialize these private fields I can annotate all those classes with the following…
Tag: spring
return throw exception in Kotlin
I have the following problem, I can’t return this exception. It’s giving an error 500 and doesn’t run this exception. I wish that when I entered the if it would already return this custom exception. KOTLIN JAVA Answer You need to use RestControllerAdvice or ControllerAdvice like
How to get an average int for a Collection of an Entity using thymeleaf?
I have an Employee Entity that has a Collection of Reviews, each Review has a byte grade. Unnecessary details are omitted for brevity How can I get an average Review grade for each Employee using Thymeleaf to insert in Table? Answer Thymeleaf has aggregate functions. You can combine them with collection proje…
correct structure in MVC with spring
I’m a little confused about correct mvc pattern. This is my config file: In this class I’ve got all Beans. This is my interface UserRepo, and interface UserService. They are the same I’ve got my class that implemets this interface And finally I’ve got my Controller In my Controller I @…
Failed to determine a suitable driver class spring
When I run my Spring Boot project, I get this error: Description: Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured. Reason: Failed to determine a suitable driver class Action: Consider the following: If you want an embedded database …
Property file reading error in spring boot
Below is my yml file in spring boot app below value access is working file but when I try to access in below way it gives an error. I checked it gives error only when add “com.cloudimpl.outstack.runtime.EventRepositoryFactory” this part. How can I solve this?? Answer It doesn’t work so. You …
Underscore in model class on Spring Boot
I doing the maintenance of this code please can someone explain what is that notation Post_ in the code below? I know Post is a model that I created, but Post_ with underscore is not in files. I searched but didnt find any information about this. Its a pre generated Spring Boot file? And if so how to create i…
How do I compare Integer and Long types with Junit?
How do I compare Integer and Long types with Junit ? The result of assertThat(poiList.get(0).get(“id_pk”)).isEqualTo(member.getId_pk()); is: The two types are: How can I compare 1 and 1L to be equal? best regards Answer You can convert Integer to Long via java.lang.Integer#longValue: BUT beware of…
Spring Boot Patient Application
an image of code for some reason I am trying to have a little API run. Everything runs fine but I have to make an addition and am confused. I have to have it so in the URL when I type “localhost:8080/api/v1/{illness}” it will display the names of the people with that illness…help. I have inc…
Spring security application giving No AuthenticationProvider found for org.springframework.security.authentication.UsernamePasswordAuthenticationToken
I am new to spring boot. I am trying to implement a simple spring boot security with userdetailsservice in Spring Tool Suite(STS). Below is the controller I used: And the Web security configuration code: I gave all the required dependencies in pom.xml. So, I have added below line in application.propperties fi…