I am running my Maven/Spring project in Jenkins (just testing it out, first time) using the shell script option with: mvn spring-boot:run I get the build error: /Users/Shared/Jenkins/tmp/jenkins8087926087546049217.sh: line 2: mvn: command not found How can I fix this? Its a Spring-boot app. It works fine when…
Tag: spring
How to catch non-MVC and non-REST exceptions in Spring Boot
I’ve been able to find endless amounts of tutorials on how to catch unhandled exceptions in Spring MVC or Spring REST, but what I want to know is how to catch unhandled exceptions without using the Spring Web framework at all. I am writing an application which does not have a web component, and I am not…
@PreUpdate doesn’t save parent object when it’s updated
I have two entities with relation one to many. Parent can have several Child entity instances. I added a field to the parent that stores the date of children modifications(childrenLastModifiedDate). To maintain that, I added method: Here is the problem. It’s not always invoke when the child is saved. Lo…
Spring RestTemplate getForObject getting 404
I’m trying to make a get request to an Api Rest but I’m always getting 404, nevertheless if try copying queryUrl in a browser or postMan it works perfectly. restTemplate.getForObject(queryUrl, entity ,Integer.class); I’ve also tried this: HttpHeaders httpHeaders = new HttpHeaders(); httpHead…
Query-by-example skip primitives?
Spring supports creating queries by examples of the object to look for. Like: Problem: if the @Entity has primitive fields, then their default value will actually be used for creating the query. The example above will result in: SELECT * from persons where lastname := ‘Smith’ and age := 0 In my ex…
Inject html into thymeleaf template
I have thymeleaf templates lying in database, First I retrieve template and process it: So now processedTemplate contains html as a String. Then I retrieve another template and do basically the same, but I want also inject previous template into it, so the java code should look like: So what should I put into…
SpringBoot 401 UnAuthorized even with out security
I did not use Spring Security but it is asking me to authenticate. Exception for URL(http://localhost:8080/SpringJob/ExecuteJob): application-dev.xml build.gradle snippet Controller Answer Try to add below lines in your application.properties file According to spring doc, use security.ignored= Comma-separated…
Spring REST partial update with @PATCH method
I’m trying to implement a partial update of the Manager entity based in the following: Entity SaveManager method in Controller Save object manager in Dao impl. When I save the object the username and password has changed correctly but the others values are empty. So what I need to do is update the usern…
How to assign a value from application.properties to a static variable?
I am using Spring MVC. I have a UserService class annotated with @Service that has a lot of static variables. I would like to instantiate them with values from the application.properties file. For example in application.properties I have: SVN_URL = http://some.url/repositories Then in the class there is: @Val…
Spring Boot Controller not mapping
I have used STS and now I am using IntelliJ Ultimate Edition but I am still getting the same output. My controller is not getting mapped thus showing 404 error. I am completely new to Spring Framework. DemoApplication.java HelloController.java Console Output Answer I too had the similar issue and was able to …