I have the following project structure in my Spring boot app, in which I want to use Thymeleaf but the spring-boot cannot find my template directory and is showing warning Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration) PS: I am using @Ena…
Tag: spring
Spring/NetBeans – java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
Whenever I try to run my java project, I get file not found exception saying that beans.xml cannot be found. I am using NetBeans and have read that I might need to set my classpath to the correct directory or the project will not run correctly (Eclipse does this automatically(?)). Running this same program wi…
Return custom object from Spring Data with Native Query
My question is based on another post. How can I achieve the same with a native query? Native queries do not allow JPQL thus do not allow new instances either. My POJO. My database table contains coordinates for cities perimeter, so there are three columns: city_name, latitude, longitude. Each city contains lo…
java.io.FileNotFoundException: class path resource cannot be opened because it does not exist
I am trying to set the configuration location for my Project but I keep getting the following error: java.io.FileNotFoundException: class path resource [main/resources/app-context.xml] cannot be opened because it does not exist I have my project set up like this: And I have my code set up as: How can I fix th…
How to log time taken by Rest web service in Spring Boot?
I am writing a web Rest web service using Spring Boot. I want to log time taken by my webservice to process request. Also I want to log headers,method and URI called. I have done similar in my jersey web service few months back using ContainerRequestFilter and ContainerResponseFilter filter() method. Also, AO…
How to log errors in a EnvironmentPostProcessor execution
I have created an EnvironmentPostProcessor in SpringBoot to fetch properties from database and attached it to the Spring’s Environment as a PropertySource. This is the code I have: And this is the main/META-INF/spring-factories file had to be created: The code works well, it fetches from the db what I n…
Gradle project error – java.lang.ClassNotFoundException: org.springframework.boot.SpringApplication
This is my main application code: I’m using gradle to build the project. Even though SpringApplication file is properly imported I’m getting the following error: I’m getting following gradle message when I hover over SpringApplication Any help would be much appreciated. Thanks in advance! An…
Spring and JMS DynamicDestinationResolution
I am using the latest Spring 4 and ActiveMQ to put JMS messages on a queue. Using the JMSTemplate, I have a default queue, and the sample code I have lets me put a message on the default queue with no issues. There is also a sample code that lets me put a message on a Destination … this is
Synchronize Gradle projects with workspace failed
I’ve the Spring Tool Suite v3.8.3 and its component Spring IDE v3.8.4.201702201939-CI-B1500. I’ve also the Gradle Buildship v2.0. I created a project with JHipster v4.0.5 but is not possible to import it. (there were not errors before the Gradle Buildship 2). Below the error: Synchronize Gradle pr…
Java 8 generic Retry if specific exception
I’m finding myself writing alot of retry loops that look like I want to write a generic function that accepts a Lambda and only retries on a specific error (in the above case thats SocketTimeoutException). I’ve seen some functions that accept a Runnable which is fine, but they don’t seem to …