I’m working on spring boot 2 application and trying to establish connection with postgresql database with configuring hikari datasource and spring Jpa. I’m succeed in that and i’m using hibernate.hbm2ddl.auto as update so it is creating table if not exists, but only the problem is it is thro…
Tag: spring-boot
How do you specify default values for Jackson deserialization
Up here is my Controller code. Up here is my User class code. When I POST the JSON above, I get the age property to be null. I want Jackson to deserialize the empty fields (“” or null) in JSON with default values. Like this: What should I do? Answer You can define a custom getter property where se…
How do I force a Spring Boot JVM into UTC time zone?
I saw Force Java timezone as GMT/UTC I tried mvn spring-boot:run -Dexec.args=”-Duser.timezone=GMT” mvn spring-boot:run -Dexec.args=”-Duser.timezone=UTC” user.timezone=UTC in config/application.properties user.timezone=GMT In the pom.xml: mvn spring-boot:run -Dspring-boot.run.jvmArgumen…
Spring Boot: How to disable Tomcat startup logging?
I’m using Spring Boot 2.0.x with Logback. On startup of my application (using an embedded tomcat), I see several INFORMATION log messages (written to standard error) which apparently originate directly from the embedded tomcat. In contrast to the rest of all my logging, these messages seem to not be wri…
Spring: Check if a classpath resource exists before loading
I have a code where I need to check if a classpath resource exists and apply some actions. Problem: ResourceUtils.getFile() throws FileNotFoundException if the resource doesn’t exist. At the same time I don’t want to use exceptions for code flow and I’d like to check if a resource exists. Qu…
Is there a way to use @OneToMany and @ManyToMany to handle polymorphism in hibernate
I am working on app that uses microservices architecture, i have project A which has this entity User with this code and another entity Authority and i have project B which has entity AAA with this code: so when i run the the project B I get the following error: org.hibernate.AnnotationException: Use of @OneT…
How to get the value from system property in spring boot
I am using following command to run my spring boot application Currently, I am able to access it via following command like below However I need to access it via any annotation in Spring something like @value(${library.system.property}) I tried to use But the value of the property is null. Do I need to use co…
Custom RestTemplate using requestFactory of RestTemplateBuilder in SpringBoot 2.1.x is not backward compatible with version 1.5.x
In Spring Boot 1.5.x, I was creating a custom RestTemplate like below: But, after migrating to Spring Boot 2.1.x, the above code doesn’t compile. Looks like requestFactory doesn’t take HttpComponentsClientHttpRequestFactory as an input parameter. Can anyone suggest how can I make the above code wo…
Why this error coming failed to load elasticsearch nodes in spring boot?
I am trying to use elasticsearch in my webapplication. I am using spring boot 2.0.6. I didn’t add any configuration file elastic search is auto configured by spring boot. I added spring data elastic search properties in application.properties like this spring-data-elasticsearch-3.0.11 elasticsearch-5.6.…
Put user in HttpSession with Spring Security default login and authenticate
I precise that I am a french student in 1st year of Java Developper. I’m developing a little multi-module app using: Spring Boot, Spring security, Hibernate, Spring Data, Spring MVC and Thymeleaf. I would like to set the User in the session, or at least the userId, at login. This way I don’t have …