Skip to content
Advertisement

Tag: spring

Spring Data MongoDB Annotation @CreatedDate isn’t working, when ID is assigned manually

I’m trying to use auditing to save dateCreated and dateUpdated in my objects, but since I set ID manually, there’s some additional work. Following Oliver Gierke’s suggestion in DATAMONGO-946 I’m trying to figure out how to correctly implement it. As original poster in Jira task above, I’ve downloaded example from here https://github.com/spring-guides/gs-accessing-data-mongodb.git and modified it a bit: and and a

validation with double value in Spring

I want to check score which have value: 0.00 <= value<= 10.00 I used: -Model(Score): -messages.properties: -servlet-context.xml: But the value = 10.01 has passed the check. Please help me. Answer I resolve my proplem with: Thank you lots @ Kayaman ,@hyness

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

HTTP Status 405 – Request method ‘PUT’ not supported

I have the following controller: Here is my calls from the PostMan. First I am making the GET call to get all the restaurants and it works fine Second I am trying to update the object by I am getting the following error. At the Tomcat 8.0.32, I am getting the following log: 13-Feb-2016 16:55:09.442 WARNING [http-apr-8080-exec-9] org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method

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

Does Spring Boot support multimodule maven projects?

I’m just curious about the level of support Spring Boot has for multimodule maven projects. There’s so much work that has to be done when creating a good layered set of projects (especially getting the various JPA/JDO enhancers set up). All of the samples I’ve seen put everything into one project, which is fine for simple demos. Can Spring Boot

Difference between registerGlobal(), configure(), configureGlobal(),configureGlobalSecurity in Spring security

I have below three code snippets all doing the same thing: creating in-memory authentication. So how it impacts defining it in different method names? registerGlobal configure configureGlobal configureGlobalSecurity First one: Second one: Third one: Fourth: UPDATE 1 : One more thing I would like to add: configure() method is present in WebSecurityConfigurerAdapter class while others are not present. UPDATE 2:

How to validate CronSequenceGenerator cron expressions?

How could I validate cron expressions that are prepared for use of CronSequenceGenerator? I mean, I cannot wait until the cron executes automatically as I’m defining like monthly intervals. Is the following correct? How can I be sure? Answer The Spring’s CronSequenceGenerator class has a method isValidExpression(String expression) which takes the cron expression and returns a boolean.

Advertisement