Skip to content
Advertisement

Tag: spring-mvc

What will happen if we interchange @service and @repository annotation in the spring MVC

Why we needs to use @service inside the service Implementation and @repository in the DAO Implementation. There are no problem occur when I interchange the @service and @repository annotation in the spring MVC. Answer According to documentaion @Repository,@Service,@Controller are all synonyms. They all are just specializations of @Component annotation. So, generally, they can be used one instead of other. But

Spring Boot @ExceptionHandler hide Exception Name

I am using Spring Boot 1.3.X and have the following: Which works as expected. When passing a wrong param, the following exception is raised: I then created an ExceptionHandler as seen below: Which raises the following Exception: Is it possible to exclude the exception field from the JSON representation? Answer You can get the Error Attributes in your controller advice

Spring Boot classpath

In the Spring Boot’s docs here, about serving static content, it says: By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath. I found that all the content in the directory: will be copied inside the classpath, so I can put my static content in: and all will

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

Not supported for DML operations with JPA update query

This has been asked once before but the solution did not solve the issue. I am creating a JUnit test: The query the above test is calling is: Error: Answer The @Modifying annotation must be placed on the updateMaterialInventory method, along to the @Query annotation, to let Spring-data know that the query is not a query used to select values,

Advertisement