Spring boot restful web service staandalone app startup time very slow - spring-boot

When running my restful web service using spring boot as a standalone application, if I run it as a JAR the JVM hangs during startup for around 4-5 minutes (there is no output to console, no Spring Boot Symbol for a long time initially). The entire application takes around 26 minutest to load. If I run the application from Eclipse or package it as war and deploy it, the entire startup time is under 20 seconds.. I can't figure out what the problem is. Followed the instructions in https://spring.io/guides/gs/rest-service/
If I create the exact same spring demo application (greeting etc.) as per the link above the JVM takes around a minute to show the Spring Boot symbol. After that the application starts to load at super slow rate. Final line that I get from this simple application is:
2016-03-10 14:39:58.336 INFO 10344 --- [main] com.deepak.springbootrest.Application : Started Application in 204.826 seconds (JVM running for 254.923)
Startup time is fine when I run it from Eclipse. In eclipse, i see: 2016-03-10 14:56:56.019 INFO 24368 --- [ main] com.deepak.springbootrest.Application : Started Application in 3.452 seconds (JVM running for 4.426)
I am using JDK 1.7, which I assume should be fine.
EDIT: Application startup crawls with: C:\dev\sw\jdk\jdk1.7.0_45\bin\java.exe -Dfile.encoding=UTF-8 -jar target\spring-boot-rest-0.0.1-SNAPSHOT.jar
If I put what eclipse is using on the command line:
C:\dev\sw\jdk\jdk1.7.0_45\bin\java.exe -Dfile.encoding=UTF-8 -classpath C:\dev\bak\files\personal\train\code\tools\spring-boot-rest\target\classes;C:\Users\abrahd2.m2\repository\org\springframework\boot\spring-boot-starter-web\1.3.3.RELEASE\spring-boot-starter-web-1.3.3.RELEASE.jar;........OMITTED.....C:\Users\abrahd2.m2\repository\org\springframework\spring-expression\4.2.5.RELEASE\spring-expression-4.2.5.RELEASE.jar com.deepak.springbootrest.Application
it starts in under 4 seconds
The output from the slow-mo startup log is:
*. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.3.RELEASE)
2016-03-10 15:23:19.061 INFO 25576 --- [ main] com.deepak.springbootrest.Application : Starting Application v0.0.1-SNAPSHOT on INENABRAHD2L2C with PID 25576 (C:\dev\bak\files\personal\train\code\tools\spring-boot-rest\target\spring-boot-rest-0.0.1-SNAPSHOT.jar started by abrahd2 in C:\dev\bak\files\personal\train\code\tools\spring-boot-rest)
2016-03-10 15:23:19.625 INFO 25576 --- [ main] com.deepak.springbootrest.Application : No active profile set, falling back to default profiles: default
2016-03-10 15:23:25.529 INFO 25576 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#f1a0fad: startup date [Thu Mar 10 15:23:25 IST 2016]; root of context hierarchy
2016-03-10 15:24:14.317 INFO 25576 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-03-10 15:25:15.962 INFO 25576 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-03-10 15:25:17.014 INFO 25576 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-03-10 15:25:17.198 INFO 25576 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.32
2016-03-10 15:25:25.059 INFO 25576 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-03-10 15:25:25.060 INFO 25576 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 119533 ms
2016-03-10 15:25:33.350 INFO 25576 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-03-10 15:25:33.721 INFO 25576 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-03-10 15:25:33.721 INFO 25576 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-03-10 15:25:33.721 INFO 25576 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-03-10 15:25:33.721 INFO 25576 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-03-10 15:25:49.180 INFO 25576 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#f1a0fad: startup date [Thu Mar 10 15:23:25 IST 2016]; root of context hierarchy
2016-03-10 15:25:59.257 INFO 25576 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/greeting]}" onto public com.deepak.springbootrest.Greeting com.deepak.springbootrest.GreetingController.greeting(java.lang.String)
2016-03-10 15:25:59.352 INFO 25576 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-03-10 15:25:59.352 INFO 25576 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2016-03-10 15:25:59.864 INFO 25576 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-10 15:25:59.864 INFO 25576 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-10 15:26:01.305 INFO 25576 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-03-10 15:26:05.504 INFO 25576 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-03-10 15:26:10.089 INFO 25576 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-03-10 15:26:10.552 INFO 25576 --- [ main] com.deepak.springbootrest.Application : Started Application in 208.006 seconds (JVM running for 258.259)*
Adding code and pom, which is what is there in the spring guide:
package com.deepak.springbootrest;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Run with mvn spring-boot:run or java -jar target/<name of jar> Run with
* http://localhost:8080/greeting
*
* #author abrahd2
*
*/
#SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
package com.deepak.springbootrest;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
#RestController
public class GreetingController {
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
#RequestMapping("/greeting")
public Greeting greeting(#RequestParam(value="name", defaultValue="World") String name) {
return new Greeting(counter.incrementAndGet(),
String.format(template, name));
}
}
package com.deepak.springbootrest;
public class Greeting {
private final long id;
private final String content;
public Greeting(long id, String content) {
this.id = id;
this.content = content;
}
public long getId() {
return id;
}
public String getContent() {
return content;
}
}
Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.3.RELEASE</version>
</parent>
<groupId>com.deepak.test</groupId>
<artifactId>spring-boot-rest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Spring boot rest api</name>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<properties>
<java.version>1.7</java.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

Related

Spring Boot controller returns 404 for all api endpoints

I am new to Spring's ecosystem. And I am stuck with this particular situation. My application server responds with 404 for all of my API endpoints.
This is my controller
package com.example.controllers;
import com.example.models.Movie;
import com.example.services.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
#RestController
public class MovieController {
#Autowired
private MovieService movieService;
#RequestMapping(value = "/movies", method = RequestMethod.GET)
#ResponseBody
public List<Movie> getAllMovies(){
return movieService.getAllMovies();
}
#RequestMapping(value = "/movies", method = RequestMethod.POST)
#ResponseBody
public Movie addNewMovie(#RequestBody Movie movie){
System.out.println("Hello World");
return movieService.addMovie(movie);
}
#RequestMapping(value = "/movies/{id}", method = RequestMethod.GET)
#ResponseBody
public Optional<Movie> getMovieById(#PathVariable String id){
return movieService.getMovieById(id);
}
#RequestMapping(value = "/movies", method = RequestMethod.PUT)
#ResponseBody
public Movie updateMovie(#RequestBody Movie movie){
return movieService.updateMovie(movie);
}
#RequestMapping(value = "/movies/{id}", method = RequestMethod.DELETE)
public void removeMovieById(#PathVariable String id){
movieService.deleteMovie(id);
}
}
And this my main class
package com.example;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
#EnableAutoConfiguration
#ComponentScan
#SpringBootApplication
public class LearnSpringApplication{
public static void main(String[] args) {
SpringApplication.run(LearnSpringApplication.class, args);
}
}
I am running it on localhost and port is 8080. I did set up a small app prior to this one, and that worked as expected. However, I am guessing that it's because the controller is in a different package since in the previous app, the main class and the controller were in the same package.
Edit Here's my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>learn_spring</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<name>learn_spring</name>
<description>Project to learn Spring</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>10</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
EDIT My Spring-Boot startup logs are
2018-05-03 17:16:44.937 INFO 14017 --- [ main] com.example.LearnSpringApplication : Starting LearnSpringApplication v0.0.1 on tfc with PID 14017 (/home/ayush/Workspace/learn_spring/target/learn_spring-0.0.1.jar started by ayush in /home/ayush/Workspace/learn_spring)
2018-05-03 17:16:44.940 INFO 14017 --- [ main] com.example.LearnSpringApplication : No active profile set, falling back to default profiles: default
2018-05-03 17:16:45.045 INFO 14017 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#6aba2b86: startup date [Thu May 03 17:16:45 IST 2018]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/home/ayush/Workspace/learn_spring/target/learn_spring-0.0.1.jar!/BOOT-INF/lib/spring-core-5.0.5.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2018-05-03 17:16:46.113 INFO 14017 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-05-03 17:16:46.138 INFO 14017 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-05-03 17:16:46.139 INFO 14017 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.29
2018-05-03 17:16:46.151 INFO 14017 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib]
2018-05-03 17:16:46.218 INFO 14017 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-05-03 17:16:46.218 INFO 14017 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1186 ms
2018-05-03 17:16:46.336 INFO 14017 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-05-03 17:16:46.339 INFO 14017 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-05-03 17:16:46.340 INFO 14017 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-05-03 17:16:46.340 INFO 14017 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-05-03 17:16:46.340 INFO 14017 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-05-03 17:16:46.455 INFO 14017 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-03 17:16:46.720 INFO 14017 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#6aba2b86: startup date [Thu May 03 17:16:45 IST 2018]; root of context hierarchy
2018-05-03 17:16:46.786 INFO 14017 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-05-03 17:16:46.787 INFO 14017 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-05-03 17:16:46.817 INFO 14017 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-03 17:16:46.817 INFO 14017 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-05-03 17:16:47.060 INFO 14017 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2018-05-03 17:16:47.151 INFO 14017 --- [localhost:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:12}] to localhost:27017
2018-05-03 17:16:47.155 INFO 14017 --- [localhost:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 3]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=2192957}
2018-05-03 17:16:47.323 INFO 14017 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-05-03 17:16:47.392 INFO 14017 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2018-05-03 17:16:47.395 INFO 14017 --- [ main] com.example.LearnSpringApplication : Started LearnSpringApplication in 2.89 seconds (JVM running for 3.296)
Sometimes is because of your package structure. Always make sure your controllers are in same package or sub-package level as the #SpringBootApplication class.
For example:
If application class is at com.a.b then controllers should be at com.a.b or com.a.b.c or com.a.b.c.d etc. You don't always have to add #ComponentScan to get them registered.
You're using IntelliJ IDEA community version, which does not support the Spring Framework:
see https://www.jetbrains.com/idea/features/editions_comparison_matrix.html for reference
Update
Since you're using the command line, then the above does not apply. I'll leave it here as a reference, though.
In the comments, you have specified that when running mvn clean package followed by java -jar target/whatever-your-project-name-is.jar, you get the following error:
Field movieService in com.example.controllers.MovieController required a bean of type 'com.example.services.MovieService' that could not be found.
Please make sure that:
you have a class MovieService in the package services
that class is annotated with the #Service annotation
Update 2
Since the above did not work, try replacing
#ComponentScan
by
#ComponentScan({"com.example.services", "com.example.controllers"})
in your LearnSpringApplication class.
Include all other packages that have classes annotated with #Component, #Service, #Controller, #RestController, or #Repository.
Note that this is a workaround. Normally, having #ComponentScan alone should be sufficient -- or as #DarrenForsythe mentionned in the comment, even just #SpringBootApplication should be sufficient for your case.
I had the same problem today and tried the simple solution provided above by #Daniel Moshi. It worked fine. Thanks.
Other option is using like below:
#SpringBootApplication(scanBasePackages = "com.example")
...with this the Controller can stay in any sub-package of com.example and works good even without explicit usage of #ComponentScan.

Spring Boot controller required a bean of type 'org.dozer.Mapper' that could not be found

I've created a spring boot project and added
compile('net.sf.dozer:dozer:5.5.1')
to dependencies. But the class, org.dozer.Mapper, is not recognized by my app.
I run gradle clean, gradle buildDependents and gradle build.
But things did not changed.
What should I do ?
my build.gradle
buildscript {
ext {
springBootVersion = '2.0.0.RC1'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.everglowtrading'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repository.jboss.org/nexus/content/repositories/releases" }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-aop')
compile('org.flywaydb:flyway-core')
compile('org.springframework.boot:spring-boot-starter-hateoas')
compile('org.mybatis.spring.boot:mybatis-spring-boot-starter:1.3.1')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.data:spring-data-commons')
compile('com.h2database:h2')
compile('net.sf.dozer:dozer:5.5.1')
runtime('org.springframework.boot:spring-boot-devtools')
runtime('com.h2database:h2')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('io.projectreactor:reactor-test')
}
The controller
package com.myproject.stock.controllers;
import java.io.IOException;
import java.util.List;
import java.util.Locale;
import javax.servlet.http.HttpServletResponse;
import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
import com.myproject.stock.domain.model.Stock;
import com.myproject.stock.domain.repository.StockCriteria;
import com.myproject.stock.form.StockListForm;
import com.myproject.stock.service.StockService;
#RestController
public class StockController {
private static final int DEFAULT_PAGEABLE_SIZE = 5;
#Autowired
Mapper beanMapper;
#Autowired
StockService<Integer> stockService;
#Autowired
MessageSource msg;
#RequestMapping("/")
void index(HttpServletResponse response) throws IOException {
response.sendRedirect("/stock");
}
#RequestMapping("/stock")
public ModelAndView stock(ModelAndView mav) {
Stock stock = stockService.getItems(11);
List<Stock> stockList = stockService.getAllItems();
String message = msg.getMessage("stock.label", null, Locale.JAPAN);
mav.addObject("stock_id", stock.getId());
mav.addObject("stockList", stockList);
mav.addObject("message", message);
mav.addObject("stockBuildingName", stock.getBuilding_name());
mav.setViewName("stock/search/index");
return mav;
}
#RequestMapping("/stock/search")
public String index(#Validated StockListForm stockListForm
, BindingResult bindingResult
, Pageable pageable
, Model model) {
StockCriteria criteria = beanMapper.map(stockListForm, StockCriteria.class);
Page<Stock> page = stockService.findPageByCriteria(criteria, pageable);
model.addAttribute("page", page);
return "stock/search/index";
}
}
the error message
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.RC1)
2018-02-19 22:15:35.648 INFO 7950 --- [ restartedMain] c.e.wms.stock.WmsApplication : Starting WmsApplication on YatabeMBP.local with PID 7950 (/Users/ayatabe/dev/wms-stock/build/classes/java/main started by ayatabe in /Users/ayatabe/dev/wms-stock)
2018-02-19 22:15:35.648 INFO 7950 --- [ restartedMain] c.e.wms.stock.WmsApplication : No active profile set, falling back to default profiles: default
2018-02-19 22:15:35.695 INFO 7950 --- [ restartedMain] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#82f0a7d: startup date [Mon Feb 19 22:15:35 JST 2018]; root of context hierarchy
2018-02-19 22:15:36.772 INFO 7950 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$d86c709b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-02-19 22:15:37.104 INFO 7950 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 9090 (http)
2018-02-19 22:15:37.114 INFO 7950 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-02-19 22:15:37.114 INFO 7950 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.27
2018-02-19 22:15:37.127 INFO 7950 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/Users/ayatabe/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-02-19 22:15:37.209 INFO 7950 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-02-19 22:15:37.209 INFO 7950 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1517 ms
2018-02-19 22:15:37.369 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-02-19 22:15:37.371 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet webServlet mapped to [/h2console/*]
2018-02-19 22:15:37.374 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-02-19 22:15:37.374 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-02-19 22:15:37.374 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-02-19 22:15:37.374 INFO 7950 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-02-19 22:15:37.415 WARN 7950 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'stockController': Unsatisfied dependency expressed through field 'beanMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.dozer.Mapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {#org.springframework.beans.factory.annotation.Autowired(required=true)}
2018-02-19 22:15:37.417 INFO 7950 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-02-19 22:15:37.434 INFO 7950 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-02-19 22:15:37.550 ERROR 7950 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field beanMapper in com.myproject.stock.controllers.StockController required a bean of type 'org.dozer.Mapper' that could not be found.
Action:
Consider defining a bean of type 'org.dozer.Mapper' in your configuration.
You haven't define a bean for org.dozer.Mapper type so Spring can't inject a proper instance to your controller class.
The simplest way to define this bean is to add following method to your main Spring application class:
#Bean
public Mapper mapper() {
return new DozerBeanMapper();
}
Alternatively you can put it in any #Configuration annotated class.
For those who might run into the same problem as me:
Add #MapperScan("yourMapperPath") at your spring boot main launch class. If the notation shows as red, reimport your mybatis-spring-boot-starter dependency:
Go to your project pom.xml > right click on the artifactId > Maven > Reimport
I thought I have imported the dependency days ago, but the project didn't.

Spting cloud data flow batch job is running one time if #EnableTask is used in main app

Hi I am trying to deploy simple spring boot batch jar file in local spring cloud data flow server. I am facing serious problem in the batch when I am using #EnableTask in my main java class. When I am using #EnableTask in my application the batch job is running only one time. Its executing the batch and then de registering the application automatically. Code for the application is given below.
1)main class
package com.jwt.spring.batch;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
#EnableTask
#EnableBatchProcessing
#SpringBootApplication
public class ScdfBatchApplication {
public static void main(String[] args) {
SpringApplication.run(ScdfBatchApplication.class, args);
}
}
2)JobConfiguration.java
package com.jwt.spring.batch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
#Configuration
public class JobConfiguration {
private static final Log logger = LogFactory.getLog(JobConfiguration.class);
#Autowired
public JobBuilderFactory jobBuilderFactory;
#Autowired
public StepBuilderFactory stepBuilderFactory;
#Bean
public Job job() {
return jobBuilderFactory.get("job").start(stepBuilderFactory.get("jobStep1").tasklet(new Tasklet() {
#Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
logger.info("Job was run");
return RepeatStatus.FINISHED;
}
}).build()).build();
}
}
3)pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.jwt.spring.batch</groupId>
<artifactId>SCDFBatch</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SCDFBatch</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud-task.version>1.2.2.RELEASE</spring-cloud-task.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-task</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>${spring-cloud-task.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Below is the log of the application
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.5.9.RELEASE)
2018-01-05 17:13:37.984 INFO 14436 --- [ main] c.jwt.spring.batch.ScdfBatchApplication : Starting ScdfBatchApplication on bdc7-l-5065XBS with PID 14436 (C:\STS-WORK_SPACE\SPRING-BATCH\SCDFBatch\target\classes started by mukesh.bo.kumar in C:\STS-WORK_SPACE\SPRING-BATCH\SCDFBatch)
2018-01-05 17:13:37.990 INFO 14436 --- [ main] c.jwt.spring.batch.ScdfBatchApplication : No active profile set, falling back to default profiles: default
2018-01-05 17:13:38.091 INFO 14436 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e725a: startup date [Fri Jan 05 17:13:38 IST 2018]; root of context hierarchy
2018-01-05 17:13:39.153 INFO 14436 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.cloud.task.configuration.SimpleTaskConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in org.springframework.cloud.task.configuration.SimpleTaskConfiguration] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/SimpleBatchConfiguration.class]]
2018-01-05 17:13:39.784 WARN 14436 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.stepScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean javadoc for complete details.
2018-01-05 17:13:39.804 WARN 14436 --- [ main] o.s.c.a.ConfigurationClassEnhancer : #Bean method ScopeConfiguration.jobScope is non-static and returns an object assignable to Spring's BeanFactoryPostProcessor interface. This will result in a failure to process annotations such as #Autowired, #Resource and #PostConstruct within the method's declaring #Configuration class. Add the 'static' modifier to this method to avoid these container lifecycle issues; see #Bean javadoc for complete details.
2018-01-05 17:13:39.943 INFO 14436 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration' of type [org.springframework.cloud.task.batch.configuration.TaskBatchAutoConfiguration$$EnhancerBySpringCGLIB$$e6554726] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-05 17:13:39.952 INFO 14436 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$60e59b9a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-05 17:13:40.005 INFO 14436 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.task.batch.listener.BatchEventAutoConfiguration' of type [org.springframework.cloud.task.batch.listener.BatchEventAutoConfiguration$$EnhancerBySpringCGLIB$$2eab5129] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-01-05 17:13:40.955 INFO 14436 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2018-01-05 17:13:40.971 INFO 14436 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-01-05 17:13:40.972 INFO 14436 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.23
2018-01-05 17:13:41.201 INFO 14436 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-01-05 17:13:41.202 INFO 14436 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3116 ms
2018-01-05 17:13:41.540 INFO 14436 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-01-05 17:13:41.544 INFO 14436 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-01-05 17:13:41.545 INFO 14436 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-01-05 17:13:41.545 INFO 14436 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-01-05 17:13:41.545 INFO 14436 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-01-05 17:13:42.681 INFO 14436 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [org/springframework/cloud/task/schema-h2.sql]
2018-01-05 17:13:42.726 INFO 14436 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [org/springframework/cloud/task/schema-h2.sql] in 45 ms.
2018-01-05 17:13:43.076 INFO 14436 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e725a: startup date [Fri Jan 05 17:13:38 IST 2018]; root of context hierarchy
2018-01-05 17:13:43.170 INFO 14436 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2018-01-05 17:13:43.172 INFO 14436 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2018-01-05 17:13:43.206 INFO 14436 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 17:13:43.207 INFO 14436 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 17:13:43.314 INFO 14436 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-01-05 17:13:43.415 INFO 14436 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [org/springframework/batch/core/schema-h2.sql]
2018-01-05 17:13:43.435 INFO 14436 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [org/springframework/batch/core/schema-h2.sql] in 20 ms.
2018-01-05 17:13:43.592 INFO 14436 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-01-05 17:13:43.603 INFO 14436 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2018-01-05 17:13:43.721 INFO 14436 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2018-01-05 17:13:43.725 INFO 14436 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: []
2018-01-05 17:13:43.730 INFO 14436 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: H2
2018-01-05 17:13:43.913 INFO 14436 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2018-01-05 17:13:43.961 INFO 14436 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=job]] launched with the following parameters: [{}]
2018-01-05 17:13:43.972 INFO 14436 --- [ main] o.s.c.t.b.l.TaskBatchExecutionListener : The job execution id 1 was run within the task execution 1
2018-01-05 17:13:43.981 INFO 14436 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [jobStep1]
2018-01-05 17:13:43.992 INFO 14436 --- [ main] com.jwt.spring.batch.JobConfiguration : Job was run
2018-01-05 17:13:43.998 INFO 14436 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [SimpleJob: [name=job]] completed with the following parameters: [{}] and the following status: [COMPLETED]
2018-01-05 17:13:44.003 INFO 14436 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#9e725a: startup date [Fri Jan 05 17:13:38 IST 2018]; root of context hierarchy
2018-01-05 17:13:44.004 INFO 14436 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase 0
2018-01-05 17:13:44.005 INFO 14436 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-01-05 17:13:44.278 INFO 14436 --- [ main] c.jwt.spring.batch.ScdfBatchApplication : Started ScdfBatchApplication in 6.956 seconds (JVM running for 9.208)
Please this post. You need to use the RunIdIncrementer in your job.
Spring Batch Item Reader is executing only once
First thing Please add timestamp to name of the Job to make it unique everytime its being run.
Secondly, you should use task-launcher or stream to launch your task run more than once.
Launch it using TriggerTask; with this you could either choose to launch it with fixedDelay or via a cron expression
Finally if you wanted job to be running based on some event then create and deploy your spring batch job as stream rather than deploying as task. What type of stream depends upon your requirement whether it is processor or sink. As per the details in your query, its more kind of processor hence reference examples from spring cloud stream related to processor, have pasted a sample processor application code.
Please refer https://github.com/spring-cloud/spring-cloud-stream-samples/tree/master/transform

AspectJ LTW not working with Spring Boot on unmanaged classes

I'm facing a problem on a large scale application using SpringBoot and AspectJ for logging purposes. The logging works fine for Spring Beans, but does not work for unmanaged classes (the ones I instantiate with 'new').
I've created a sample app where you can see the problem happening, you can access it here:
https://bitbucket.org/tomkro/stack_question
The application is pretty simple, the Gradle file is a common with the standard Spring Boot starters.
There are 5 relevant classes here.
Application.java, which is the main class:
#EnableAspectJAutoProxy
#EnableLoadTimeWeaving(aspectjWeaving= EnableLoadTimeWeaving.AspectJWeaving.ENABLED)
#SpringBootApplication(scanBasePackages = "com.test.*")
public class Application {
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
The AspectConfig file (which for the sake of simplicity also defines the RestController, could be easily separated files)
#RestController
#Configuration
#ComponentScan(basePackages = {"com.test"})
public class AspectConfig {
#Bean
public TestLogger testLogger(){
return new TestLogger();
}
#Autowired
TestClass testClass;
#RequestMapping("/")
public int get() {
return testClass.methodFromClass1();
}
}
The TestLogger, which defines the aspect for this app:
#Aspect
public class TestLogger {
public TestLogger() {
}
#Around("execution( * com.test.classes..*.*(..))")
public Object aroundExecution(ProceedingJoinPoint pjp) throws Throwable {
String packageName = pjp.getSignature().getDeclaringTypeName();
String methodName = pjp.getSignature().getName();
long start = System.currentTimeMillis();
System.out.println(packageName + "." + methodName + " - Starting execution ");
Object output = pjp.proceed();
Long elapsedTime = System.currentTimeMillis() - start;
System.out.println(packageName + "." + methodName + " - Ending execution ["+elapsedTime+" ms]");
return output;
}
}
And then there's two files, one managed by Spring, the other not:
TestClass1:
#Component
public class TestClass {
public int methodFromClass1() {
TestClass2 test = new TestClass2();
return test.methodFromClass2();
}
}
TestClass2
public class TestClass2 {
public int methodFromClass2() {
int a = 10;
int b = 5;
return b + a;
}
}
Also there's the aop.xml file in META-INF which specifies the Aspect
<!DOCTYPE aspectj PUBLIC "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
<weaver option="-debug">
<!-- only weave classes in our application-specific packages -->
<include within="com.test.*"/>
</weaver>
<aspects>
<!-- weave in just this aspect -->
<aspect name="com.test.utilities.TestLogger"/>
</aspects>
</aspectj>
I followed most of this build using the tutorial on the Spring documentation here , and I've been scratching my head for two days now and I can't figure out what's happening. The managed Bean logs fine, but the unmanaged one is not being logged.
I'm using the run.bat included in the project for starting, basically it does this:
call gradle build
java -javaagent:.\src\main\resources\aspectjweaver.jar -javaagent:.\src\main\resources\spring-instrument.jar -jar build\libs\Test-0.0.1-SNAPSHOT.jar
Both jars are the latest. Usually you only would need of the JAR's, but I saw someone using both and gave it a shot. This is the output after startup and execution of a call to "localhost:8080"
[LaunchedURLClassLoader#6d8a00e3] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.0.RELEASE)
2016-04-08 15:21:44.116 INFO 20400 --- [ main] com.test.Application : Starting Application on PC000BR23205 with PID 20400 (C:\git\Test\build\libs\Test-0.0.1-SNAPSHOT.jar started by tkroth in C:\git\T
est)
2016-04-08 15:21:44.120 INFO 20400 --- [ main] com.test.Application : No profiles are active
2016-04-08 15:21:44.294 INFO 20400 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2cd72cea: startup date [Fri Ap
r 08 15:21:44 BRT 2016]; root of context hierarchy
2016-04-08 15:21:44.950 INFO 20400 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope
=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; fa
ctoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]]
with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$W
ebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAut
oConfigurationAdapter.class]]
2016-04-08 15:21:45.872 INFO 20400 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-04-08 15:21:45.888 INFO 20400 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-04-08 15:21:45.891 INFO 20400 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.28
2016-04-08 15:21:45.987 INFO 20400 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-04-08 15:21:45.987 INFO 20400 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1695 ms
2016-04-08 15:21:46.342 INFO 20400 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2016-04-08 15:21:46.347 INFO 20400 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-04-08 15:21:46.348 INFO 20400 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-04-08 15:21:46.349 INFO 20400 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-04-08 15:21:46.349 INFO 20400 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-04-08 15:21:46.439 INFO 20400 --- [ main] o.s.c.w.DefaultContextLoadTimeWeaver : Found Spring's JVM agent for instrumentation
2016-04-08 15:21:46.455 INFO 20400 --- [ main] o.s.c.w.DefaultContextLoadTimeWeaver : Found Spring's JVM agent for instrumentation
[LaunchedURLClassLoader#6d8a00e3] warning javax.* types are not being woven because the weaver option '-Xset:weaveJavaxPackages=true' has not been specified
2016-04-08 15:21:46.781 INFO 20400 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#2cd72cea:
startup date [Fri Apr 08 15:21:44 BRT 2016]; root of context hierarchy
2016-04-08 15:21:46.874 INFO 20400 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public int com.test.configuration.AspectConfig.get()
2016-04-08 15:21:46.877 INFO 20400 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.sp
ringframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2016-04-08 15:21:46.878 INFO 20400 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoco
nfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2016-04-08 15:21:46.912 INFO 20400 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-08 15:21:46.912 INFO 20400 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2016-04-08 15:21:47.030 INFO 20400 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler
]
2016-04-08 15:21:47.133 INFO 20400 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2016-04-08 15:21:47.204 INFO 20400 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-04-08 15:21:47.210 INFO 20400 --- [ main] com.test.Application : Started Application in 3.481 seconds (JVM running for 4.306)
2016-04-08 15:21:51.680 INFO 20400 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2016-04-08 15:21:51.680 INFO 20400 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2016-04-08 15:21:51.704 INFO 20400 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 23 ms
com.test.classes.TestClass.methodFromClass1 - Starting execution
com.test.classes.TestClass.methodFromClass1 - Ending execution [15 ms]
As you can see, TestClass2 is never logged, although it's called. What am I missing here?
The real question is, how can I make non-beans to be handled by LTW in a SpringBoot environment? Feel free to commit changes on the repository I provided above.

RepositoryRestResource with spring-boot CLI

I'm trying to implement a simple REST service based on a JPA repository with spring-boot and spring-data-rest. (see this tutorial) The following code works quite well if a use it with gradle:
package ch.bfh.swos.bookapp
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.*
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.context.annotation.Import
import org.springframework.data.rest.core.annotation.RepositoryRestResource
import org.springframework.data.repository.CrudRepository
import javax.persistence.*
#Configuration
#ComponentScan
#EnableAutoConfiguration
#EnableJpaRepositories
#Import(RepositoryRestMvcConfiguration.class)
class Application {
static void main(String[] args) {
SpringApplication.run Application, args
}
}
#RepositoryRestResource(path = "authors")
interface AuthorRepository extends CrudRepository<Author, Long> {}
#Entity
class Author {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id
private String firstname
private String lastname
}
To make things even simpler i tried the same code with the spring boot CLI ("spring run" command).
package ch.bfh.swos.bookapp
#Grab("spring-boot-starter-data-jpa")
#Grab("spring-boot-starter-data-rest")
#Grab("h2")
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.context.annotation.Import
import org.springframework.data.rest.core.annotation.RepositoryRestResource
import org.springframework.data.repository.CrudRepository
import javax.persistence.*
#Configuration
#ComponentScan
#EnableAutoConfiguration
#EnableJpaRepositories
#Import(RepositoryRestMvcConfiguration.class)
#RepositoryRestResource(path = "authors")
interface AuthorRepository extends CrudRepository<Author, Long> {}
#Entity
class Author {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id
private String firstname
private String lastname
}
Unfortunately this does not seem to work. #RepositoryRestResource seems not to be automatically recognized like e.g. #RestController.
Leaving the #Configuration part in, the server starts up, but the REST repository is not created as if it would with gradle.
Does anybody know if it is possible to create a RepositoryRestResource with the spring-boot CLI and how the correct code should look like?
You need a class definition to hang the #Import from (the other annotations that go on a class and not an interface are redundant).
Update: and (more importantly) Hibernate can't find your annotated classes unless they are actually in a file (it analyzes the byte code not the class definition reflectively). So you can make you app work by jarring it up and running it that way:
$ spring jar app.jar app.groovy
$ java -jar app.jar
Here's a shorter version of the app that works like that with all the redundant stuff removed:
package bookapp
#Grab("spring-boot-starter-data-jpa")
#Grab("spring-boot-starter-data-rest")
#Grab("h2")
import org.springframework.data.rest.core.annotation.RepositoryRestResource
import org.springframework.data.repository.CrudRepository
import javax.persistence.*
#Configuration
class App {}
#RepositoryRestResource(path = "authors")
interface AuthorRepository extends CrudRepository<Author, Long> {}
#Entity
class Author {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id
String firstname
String lastname
}
As suggested by Dave I tried to add the #Import statement to a class "App". The code now looks like this.
package ch.bfh.swos.bookapp
#Grab("spring-boot-starter-data-jpa")
#Grab("spring-boot-starter-data-rest")
#Grab("h2")
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.Configuration
import org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
import org.springframework.data.jpa.repository.config.EnableJpaRepositories
import org.springframework.context.annotation.Import
import org.springframework.data.rest.core.annotation.RepositoryRestResource
import org.springframework.data.repository.CrudRepository
import javax.persistence.*
#Configuration
#EnableJpaRepositories
#Import(RepositoryRestMvcConfiguration.class)
#EnableAutoConfiguration
class App {}
#RepositoryRestResource(path = "authors")
interface AuthorRepository extends CrudRepository<Author, Long> {}
#Entity
class Author {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private Long id
private String firstname
private String lastname
}
Unfortunately this doesn't work too. The Spring Data Rest seems to get initialized correctly but the RepositoryRestResource is just ignored. Calling localhost:8080 just shows { }.
Any further suggestions?
Here the output of the Spring Boot log:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.1.5.RELEASE)
2014-09-03 10:24:09.061 INFO 6264 --- [ runner-0] o.s.boot.SpringApplication : Starting application on MIMA-WS-00 with PID 6264 (C:\development\maven\repository\org\springframework\boot\spring-boot\1.1.5.RELEASE\spring-boot-1.1.5.RELEASE.jar started by rovi in C:\Users\rovi\Desktop\springboot)
2014-09-03 10:24:09.261 INFO 6264 --- [ runner-0] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#62149bcb: startup date [Wed Sep 03 10:24:09 CEST 2014]; root of context hierarchy
2014-09-03 10:24:10.248 INFO 6264 --- [ runner-0] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-09-03 10:24:10.502 INFO 6264 --- [ runner-0] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jpaMapppingContext': replacing [Root bean: class [org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension$JpaMetamodelMappingContextFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] with [Root bean: class [org.springframework.data.jpa.repository.config.JpaRepositoryConfigExtension$JpaMetamodelMappingContextFactoryBean]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null]
2014-09-03 10:24:11.293 INFO 6264 --- [ runner-0] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3e485a8b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-03 10:24:11.331 INFO 6264 --- [ runner-0] trationDelegate$BeanPostProcessorChecker : Bean 'transactionAttributeSource' of type [class org.springframework.transaction.annotation.AnnotationTransactionAttributeSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-03 10:24:11.346 INFO 6264 --- [ runner-0] trationDelegate$BeanPostProcessorChecker : Bean 'transactionInterceptor' of type [class org.springframework.transaction.interceptor.TransactionInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-03 10:24:11.359 INFO 6264 --- [ runner-0] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.config.internalTransactionAdvisor' of type [class org.springframework.transaction.interceptor.BeanFactoryTransactionAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-09-03 10:24:11.879 INFO 6264 --- [ runner-0] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-09-03 10:24:12.045 INFO 6264 --- [ runner-0] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-09-03 10:24:12.049 INFO 6264 --- [ runner-0] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.54
2014-09-03 10:24:12.212 INFO 6264 --- [ost-startStop-1] org.apache.catalina.loader.WebappLoader : Unknown loader org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader#19d59bb2 class org.springframework.boot.cli.compiler.ExtendedGroovyClassLoader$DefaultScopeParentClassLoader
2014-09-03 10:24:12.222 INFO 6264 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-09-03 10:24:12.223 INFO 6264 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2965 ms
2014-09-03 10:24:14.121 INFO 6264 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-09-03 10:24:14.133 INFO 6264 --- [ost-startStop-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2014-09-03 10:24:14.233 INFO 6264 --- [ost-startStop-1] org.hibernate.Version : HHH000412: Hibernate Core {4.3.5.Final}
2014-09-03 10:24:14.237 INFO 6264 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2014-09-03 10:24:14.239 INFO 6264 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2014-09-03 10:24:14.455 INFO 6264 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
2014-09-03 10:24:14.546 INFO 6264 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2014-09-03 10:24:14.640 INFO 6264 --- [ost-startStop-1] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2014-09-03 10:24:14.826 INFO 6264 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
2014-09-03 10:24:14.835 INFO 6264 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
2014-09-03 10:24:15.437 INFO 6264 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2014-09-03 10:24:15.440 INFO 6264 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-09-03 10:24:15.943 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.followPropertyReference(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,java.lang.String,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws java.lang.Exception
2014-09-03 10:24:15.944 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}/{propertyId}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.followPropertyReference(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,java.lang.String,java.lang.String,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws java.lang.Exception
2014-09-03 10:24:15.947 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<? extends org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.deletePropertyReference(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,java.lang.String) throws java.lang.Exception
2014-09-03 10:24:15.950 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/x-spring-data-compact+json || text/uri-list],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.followPropertyReferenceCompact(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,java.lang.String,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws java.lang.Exception
2014-09-03 10:24:15.953 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}],methods=[PATCH || PUT],params=[],headers=[],consumes=[application/json || application/x-spring-data-compact+json || text/uri-list],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<? extends org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.createPropertyReference(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.http.HttpMethod,org.springframework.hateoas.Resources<java.lang.Object>,java.io.Serializable,java.lang.String) throws java.lang.Exception
2014-09-03 10:24:15.954 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}/{property}/{propertyId}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryPropertyReferenceController.deletePropertyReferenceId(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,java.lang.String,java.lang.String) throws java.lang.Exception
2014-09-03 10:24:15.957 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/schema],methods=[GET],params=[],headers=[],consumes=[],produces=[application/schema+json],custom=[]}" onto public org.springframework.http.HttpEntity<org.springframework.data.rest.webmvc.json.JsonSchema> org.springframework.data.rest.webmvc.RepositorySchemaController.schema(org.springframework.data.rest.webmvc.RootResourceInformation)
2014-09-03 10:24:15.960 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}],methods=[HEAD],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.data.rest.webmvc.RepositoryEntityController.headCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation) throws org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.960 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.hateoas.Resources<?> org.springframework.data.rest.webmvc.RepositoryEntityController.getCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.domain.Pageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.data.rest.webmvc.ResourceNotFoundException,org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.961 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/x-spring-data-compact+json || text/uri-list],custom=[]}" onto public org.springframework.hateoas.Resources<?> org.springframework.data.rest.webmvc.RepositoryEntityController.getCollectionResourceCompact(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.domain.Pageable,org.springframework.data.domain.Sort,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.data.rest.webmvc.ResourceNotFoundException,org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.961 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryEntityController.postCollectionResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.PersistentEntityResource<?>,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.962 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}],methods=[PATCH],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryEntityController.patchItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.PersistentEntityResource<java.lang.Object>,java.io.Serializable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.web.HttpRequestMethodNotSupportedException,org.springframework.data.rest.webmvc.ResourceNotFoundException
2014-09-03 10:24:15.962 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.data.rest.webmvc.RepositoryEntityController.deleteItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable) throws org.springframework.data.rest.webmvc.ResourceNotFoundException,org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.963 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}],methods=[HEAD],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> org.springframework.data.rest.webmvc.RepositoryEntityController.headItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable) throws org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.966 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<org.springframework.hateoas.Resource<?>> org.springframework.data.rest.webmvc.RepositoryEntityController.getItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,java.io.Serializable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.966 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/{id}],methods=[PUT],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<? extends org.springframework.hateoas.ResourceSupport> org.springframework.data.rest.webmvc.RepositoryEntityController.putItemResource(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.data.rest.webmvc.PersistentEntityResource<java.lang.Object>,java.io.Serializable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler) throws org.springframework.web.HttpRequestMethodNotSupportedException
2014-09-03 10:24:15.968 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.data.rest.webmvc.RepositoryLinksResource org.springframework.data.rest.webmvc.RepositoryController.listRepositories()
2014-09-03 10:24:15.970 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/search/{search}],methods=[GET],params=[],headers=[],consumes=[],produces=[application/x-spring-data-compact+json],custom=[]}" onto public org.springframework.hateoas.ResourceSupport org.springframework.data.rest.webmvc.RepositorySearchController.executeSearchCompact(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.web.context.request.WebRequest,java.lang.String,java.lang.String,org.springframework.data.domain.Pageable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler)
2014-09-03 10:24:15.970 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/search],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.hateoas.ResourceSupport org.springframework.data.rest.webmvc.RepositorySearchController.listSearches(org.springframework.data.rest.webmvc.RootResourceInformation)
2014-09-03 10:24:15.970 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/search/{search}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.lang.Object> org.springframework.data.rest.webmvc.RepositorySearchController.executeSearch(org.springframework.data.rest.webmvc.RootResourceInformation,org.springframework.web.context.request.WebRequest,java.lang.String,org.springframework.data.domain.Pageable,org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler)
2014-09-03 10:24:15.971 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/search],methods=[HEAD],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.HttpEntity<?> org.springframework.data.rest.webmvc.RepositorySearchController.headForSearches(org.springframework.data.rest.webmvc.RootResourceInformation)
2014-09-03 10:24:15.971 INFO 6264 --- [ runner-0] o.s.d.r.w.RepositoryRestHandlerMapping : Mapped "{[/{repository}/search/{search}],methods=[HEAD],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.lang.Object> org.springframework.data.rest.webmvc.RepositorySearchController.headForSearch(org.springframework.data.rest.webmvc.RootResourceInformation,java.lang.String)
2014-09-03 10:24:16.214 INFO 6264 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-09-03 10:24:16.281 INFO 6264 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2014-09-03 10:24:16.281 INFO 6264 --- [ runner-0] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2014-09-03 10:24:16.300 INFO 6264 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-09-03 10:24:16.300 INFO 6264 --- [ runner-0] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-09-03 10:24:16.530 INFO 6264 --- [ runner-0] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2014-09-03 10:24:16.658 INFO 6264 --- [ runner-0] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080/http
2014-09-03 10:24:16.661 INFO 6264 --- [ runner-0] o.s.boot.SpringApplication : Started application in 7.952 seconds (JVM running for 10.109)
2014-09-03 10:24:27.951 INFO 6264 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2014-09-03 10:24:27.952 INFO 6264 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2014-09-03 10:24:27.974 INFO 6264 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization completed in 22 ms
Although I am late but please check if below helps you.
I have one working example and blog that uses RepositoryRestResource and EntityLinks. Please check if this helps you. On the blog you will find GitHub link too.
http://sv-technical.blogspot.com/2015/11/spring-boot-and-repositoryrestresource.html

Resources