Skip to content
Advertisement

Tag: spring

Jackson deserialization issue for ZonedDateTime

I’ve the following field in a class I use during deserialization of a service that I’m consuming. The service I’m consuming may return a Date or DateTime using the pattern: yyyy-MM-dd’T’HH:mm:ss.SSSZ Let me give 2 examples of what the service returns: 2015-11-18T18:05:38.000+0200 2015-11-18T00:00:00.000+0200 While first one works well, the latter causes the following exception to be thrown during deserialization: java.time.format.DateTimeParseException:

Mapping java.lang.String type to Postgres JSON Type

My question is related to the following question Mapping postgreSQL JSON column to Hibernate value type and although the answer works when I test passing a string to psql in postgres it doesn’t work when passing a string from my Java code. I am using MyBatis to map sql to the postgres database via Spring injection. Here is my Java

How to re-create database before each test in Spring?

My Spring-Boot-Mvc-Web application has the following database configuration in application.properties file: this is the only config I made. No any other configurations made by me anywhere. Nevertheless the Spring and subsystems are automatically recreate database on each web application run. Database is recreated namely on system run while it contains data after application ends. I was not understanding this defaults

Difference between @Bean and @Autowired

Why can’t I use @Autowired in this case? but can use @Bean Aren’t the two ways to generate BookingService the same thing? Answer @Bean and @Autowired do two very different things. The other answers here explain in a little more detail, but at a simpler level: @Bean tells Spring ‘here is an instance of this class, please keep hold of

loadOnStartup SEVERE: Servlet [dispatcher] in web application [/Producer] threw load() exception java.lang.NoSuchMethodError

I have a problem with setting up spring context using Eclipse + tomcat 8. I have checked several “Hello world” spring manuals and do not understand what is going wrong. I have the following error in console: Answer Somewhere in your classpath you have old Spring lib. AnnotationUtils from 4.2.1 contains rethrowAnnotationConfigurationException But in spring 3.2.5 – no such method

spring combine two validation annotations in one

I’m using Spring+Hibernate+Spring-MVC. I want to define a custom constraint combining two other predefined validation annotations: @NotNull @Size like this: and I want to use this annotation in my form models. UserController.java But it does not work. It accepts the less than 4 character passwords. How can I solve this problem? Answer This is a bit late, but technique of

How to mock a autowired list of Spring beans?

I’ve read plenty of articles about how to mock Spring’s bean and their autowired fields. But there is nothing I could find about autowired lists of beans. Concrete problem I’ve a class called FormValidatorManager. This class loop through several validators which implements IFormValidator. I would like to test this class. But I can’t find a way to mock validators property.

Advertisement