Unable to hit rest service running with spring boot - spring

I have configured restful webservice and hosted with the help of Spring Boot. But I'm not able to hit the service. And getting Response Status: -1 - Request Failed (Canceled or Timed-Out)
Logs:-
⁃ 2017-10-08 18:33:33.149 INFO 6806 --- [ main] com.mypleaks.PleaksRSApp : Starting PleaksRSApp on 3inmderaj1.local with PID 6806 (/Users/deraj/home/code/leaks-rs/mypleaks-rs/myPleaks-RS/target/classes started by deraj in /Users/deraj/home/code/leaks-rs/mypleaks-rs/myPleaks-RS)
⁃ 2017-10-08 18:33:33.155 INFO 6806 --- [ main] com.mypleaks.PleaksRSApp : No active profile set, falling back to default profiles: default
⁃ 2017-10-08 18:33:33.202 INFO 6806 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#311bf055: startup date [Sun Oct 08 18:33:33 IST 2017]; root of context hierarchy
⁃ 2017-10-08 18:33:33.998 INFO 6806 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'requestContextFilter' 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.jersey.JerseyAutoConfiguration; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.class]] with [Root bean: class [org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=requestContextFilter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
⁃ 2017-10-08 18:33:34.276 INFO 6806 --- [ main] f.a.AutowiredAnnotationBeanPostProcessor : JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
⁃ 2017-10-08 18:33:34.372 INFO 6806 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$af71e9e1] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
⁃ 2017-10-08 18:33:34.745 INFO 6806 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
⁃ 2017-10-08 18:33:34.756 INFO 6806 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
⁃ 2017-10-08 18:33:34.756 INFO 6806 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.6
Resource :-
Request:-
Response:-

It seems that you are using the annotations from the javax. package instead of the spring ones.
Try using #RestController on the class level and #RequestMapping on the method level (all other annotations should be from the spring package also):
#RestController
#RequestMapping(path = "/place")
public class PlaceResource{
#RequestMapping(method = RequestMethod.GET, path="/countries")
public Response getCountries(..){..}
}

Sorry Guys, Its was terrible mistake from my side. I had used below code in my application.
public class NotificationEngine implements InitializingBean {
#Override
public void afterPropertiesSet() throws Exception {"Here I was running some stupid endless process, Due to which the tomcat was not getting up completely and because of that Iwas getting this issue."}}

Please check that you have following dependency in your pom.xml, If it is not there please add it and re-run.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

Related

Spring batch process runs twice

My Spring batch process runs twice.
After reading this link here, I added spring.batch.job.enabled=false to my application.yml.
But the job itself did not run.
Then I tried doing some alterations to my job configuration Class. I moved the instance variables to method parameters hoping that would fix the issue. But no luck again.
Configuration Class
#Configuration
public class CarJobConfiguration {
private static final Logger logger = LoggerFactory.getLogger(CarJobConfiguration.class);
#Value("${com.car-update.thread-count}")
private int threadCount;
#Value("${com.car-update.delta-time}")
private int deltaTime;
#Bean
public MongoItemReader<CarMongo> carReader( #Autowired MongoTemplate mongoTemplate, #Value("${com.car-update.chunkSize}") final int chuckSize) {
MongoItemReader<CarMongo> reader = new MongoItemReader<>();
reader.setTemplate(mongoTemplate);
Map<String, Direction> sortDirection = new HashMap<>();
sortDirection.put("_id", Direction.DESC);
reader.setSort(sortDirection);
reader.setTargetType(CarMongo.class);
String query = getQuery();
logger.info("***** Mongo query *****: {}", query);
reader.setQuery(query);
reader.setPageSize(chuckSize);
return reader;
}
private String getQuery() {
// Some logic to get query
}
#Bean
public Job carDeltaJob(JobBuilderFactory jobBuilderFactory, JobCompletionNotificationListener listener, #Autowired #Qualifier("carDeltaStep")
Step carDeltaStep) {
return jobBuilderFactory.get("car_delta_extraction")
.incrementer(new RunIdIncrementer())
.listener(listener)
.flow(carDeltaStep)
.end()
.build();
}
#Bean
public Step carDeltaStep(StepBuilderFactory stepBuilderFactory,
#Value("${com.car-update.chunkSize}") final int chuckSize,
#Value("${com.car-update.thread-count}") final int threadCount,
MongoItemReader<CarMongo> mongoItemReader, CarProcessor carProcessor,
CarWriter carWriter) {
System.out.println("STEPSSSS this.chuckSize " + chuckSize +", thread count: " + this.threadCount);
return stepBuilderFactory.get("car-delta-step")
.<CarMongo, CarMongo>chunk(chuckSize)
.reader(mongoItemReader)
.processor(carProcessor)
.writer(carWriter)
.taskExecutor(taskExecutor())
.throttleLimit(threadCount)
.build();
}
#Bean
public TaskExecutor taskExecutor(){
//some logic
}
}
AppConfig.java UPDATE
#Configuration
#EnableBatchProcessing(modular=true)
public class AppConfig {
#Bean
public ApplicationContextFactory SomeOtherExtractionJob() {
return new GenericApplicationContextFactory(SomeOtherConfiguration.class);
}
#Bean
public ApplicationContextFactory carDeltaJob() {
return new GenericApplicationContextFactory(CarJobConfiguration.class);
}
}
LOGS:
03:04:57.313 INFO 9092 --- [ main] c.w.ProductExtractionApplication : Starting ProductExtractionApplication on CHMB113786.local with PID 9092 (/Users/andy/Car-Extractionbatch/bin/main started by andy in /Users/andy/Car-Extractionbatch)
03:04:57.318 INFO 9092 --- [ main] c.w.ProductExtractionApplication : No active profile set, falling back to default profiles: default
03:04:57.353 INFO 9092 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext#d78795: startup date [Thu Jun 06 03:04:57 IST 2019]; root of context hierarchy
03:04:57.774 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'catalogExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=catalogExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=catalogExtractionJobConfiguration; factoryMethodName=catalogExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CatalogExtractionJobConfiguration.class]]
03:04:57.774 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'productCategoryExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=productCategoryExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=categoryExtractionJobConfiguration; factoryMethodName=productCategoryExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CategoryExtractionJobConfiguration.class]]
03:04:57.775 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'taskExecutor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=catalogExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CatalogExtractionJobConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=categoryExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CategoryExtractionJobConfiguration.class]]
03:04:57.775 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'dimensionExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=dimensionExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dimensionExtractionJobConfiguration; factoryMethodName=dimensionExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/DimensionExtractionJobConfiguration.class]]
03:04:57.776 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'taskExecutor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=categoryExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CategoryExtractionJobConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dimensionExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/DimensionExtractionJobConfiguration.class]]
03:04:57.776 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'gwpExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=gwpExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gwpExtractionJobConfiguration; factoryMethodName=gwpExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/GwpExtractionJobConfiguration.class]]
03:04:57.777 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'taskExecutor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=dimensionExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/DimensionExtractionJobConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gwpExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/GwpExtractionJobConfiguration.class]]
03:04:57.777 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'taskExecutor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=gwpExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/GwpExtractionJobConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=carDeltaUpdateJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CarJobConfiguration.class]]
03:04:57.779 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'productRecommendedExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=productRecommendedExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=productRecommendedExtractionJobConfiguration; factoryMethodName=productRecommendedExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/ProductRecommendedExtractionJobConfiguration.class]]
03:04:57.783 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'skuExtractionJob' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=appConfig; factoryMethodName=skuExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/AppConfig.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=skuExtractionJobConfiguration; factoryMethodName=skuExtractionJob; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/SkuExtractionJobConfiguration.class]]
03:04:57.783 INFO 9092 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'taskExecutor' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=carDeltaUpdateJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/CarJobConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=skuExtractionJobConfiguration; factoryMethodName=taskExecutor; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/mycar/configuration/SkuExtractionJobConfiguration.class]]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (file:/Users/andy/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/5.0.5.RELEASE/1bd9feb1d9dac6accd27f5244b6c47cfcb55045c/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
03:04:58.414 INFO 9092 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
03:04:58.490 INFO 9092 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
03:04:58.500 INFO 9092 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: H2
03:04:58.623 INFO 9092 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
03:04:58.878 INFO 9092 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[mongo1:27017, mongo2:27017, mongo3:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
03:04:58.879 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo1:27017 to client view of cluster
03:04:58.924 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo2:27017 to client view of cluster
03:04:58.927 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo3:27017 to client view of cluster
03:04:59.051 INFO 9092 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[mongo1:27017, mongo2:27017, mongo3:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
03:04:59.052 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo1:27017 to client view of cluster
03:04:59.054 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo2:27017 to client view of cluster
03:04:59.056 INFO 9092 --- [ main] org.mongodb.driver.cluster : Adding discovered server mongo3:27017 to client view of cluster
#####from Inside JobCompletionNotificationListener construtor#####
03:04:59.193 INFO 9092 --- [ main] org.mongodb.driver.cluster : Cluster description not yet available. Waiting for 30000 ms before timing out
03:05:01.912 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:2, serverValue:816666}] to mongo2:27017
03:05:01.912 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:5, serverValue:816667}] to mongo2:27017
03:05:01.914 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:4, serverValue:510177}] to mongo1:27017
03:05:01.914 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:1, serverValue:510176}] to mongo1:27017
03:05:01.916 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:6, serverValue:1677186}] to mongo3:27017
03:05:02.206 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo1:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=288249712, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo1:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=7fffffff0000000000000127, setVersion=2, lastWriteDate=Thu Jun 06 03:05:05 IST 2019, lastUpdateTimeNanos=368580308198796}
03:05:02.207 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo3:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=290187882, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo3:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=2, lastWriteDate=Thu Jun 06 03:05:05 IST 2019, lastUpdateTimeNanos=368580309720591}
03:05:02.207 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo2:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=288378005, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo2:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=2, lastWriteDate=Thu Jun 06 03:05:05 IST 2019, lastUpdateTimeNanos=368580309928421}
03:05:02.206 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo1:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=286870787, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo1:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=7fffffff0000000000000127, setVersion=2, lastWriteDate=Thu Jun 06 03:05:05 IST 2019, lastUpdateTimeNanos=368580308253613}
03:05:02.209 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Discovered cluster type of REPLICA_SET
03:05:02.210 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Setting max election id to 7fffffff0000000000000127 from replica set primary mongo1:27017
03:05:02.210 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Discovered cluster type of REPLICA_SET
03:05:02.210 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Setting max set version to 2 from replica set primary mongo1:27017
03:05:02.211 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Setting max election id to 7fffffff0000000000000127 from replica set primary mongo1:27017
03:05:02.211 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Discovered replica set primary mongo1:27017
03:05:02.212 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Setting max set version to 2 from replica set primary mongo1:27017
03:05:02.213 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Discovered replica set primary mongo1:27017
03:05:02.216 INFO 9092 --- [reens.com:27017] org.mongodb.driver.connection : Opened connection [connectionId{localValue:3, serverValue:1677187}] to mongo3:27017
03:05:02.218 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo2:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=301879122, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo2:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=2, lastWriteDate=Thu Jun 06 03:05:05 IST 2019, lastUpdateTimeNanos=368580320523441}
03:05:02.487 INFO 9092 --- [reens.com:27017] org.mongodb.driver.cluster : Monitor thread successfully connected to server with description ServerDescription{address=mongo3:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 6, 7]}, minWireVersion=0, maxWireVersion=6, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=269161222, setName='mongodbEnterprise_lowerEnvironment', canonicalAddress=mongo3:27017, hosts=[mongo2:27017, mongo3:27017, mongo1:27017], passives=[], arbiters=[], primary='mongo1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=2, lastWriteDate=Thu Jun 06 03:05:06 IST 2019, lastUpdateTimeNanos=368580589179359}
03:05:04.645 INFO 9092 --- [ main] org.mongodb.driver.connection : Opened connection [connectionId{localValue:7, serverValue:510178}] to mongo1:27017
03:09:05.799 WARN 9092 --- [ main] o.s.b.c.s.b.FaultTolerantStepBuilder : Asynchronous TaskExecutor detected with ItemStream reader. This is probably an error, and may lead to incorrect restart data being stored.
***** Mongo query *****: {'dttm' : { $gte: ISODate('2019-06-06T02:39:06.434209Z')}}
STEPSSSS this.chuckSize 1000, thread count: 10
03:09:06.575 INFO 9092 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executing SQL script from class path resource [org/springframework/batch/core/schema-h2.sql]
03:09:06.614 INFO 9092 --- [ main] o.s.jdbc.datasource.init.ScriptUtils : Executed SQL script from class path resource [org/springframework/batch/core/schema-h2.sql] in 38 ms.
03:09:06.976 INFO 9092 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
03:09:06.980 INFO 9092 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'batchDataSource' has been autodetected for JMX exposure
03:09:06.981 INFO 9092 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Bean with name 'mariaDB' has been autodetected for JMX exposure
03:09:06.986 INFO 9092 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'mariaDB': registering with JMX server as MBean [com.zaxxer.hikari:name=mariaDB,type=HikariDataSource]
03:09:06.988 INFO 9092 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located MBean 'batchDataSource': registering with JMX server as MBean [com.zaxxer.hikari:name=batchDataSource,type=HikariDataSource]
03:09:06.992 INFO 9092 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase -2147482648
03:09:06.995 INFO 9092 --- [ main] ory$ResourceAnnotationApplicationContext : Refreshing ResourceAnnotationApplicationContext:com.mycar.configuration.CarJobConfiguration
***** Mongo query *****: {'dttm' : { $gte: ISODate('2019-06-06T02:39:07.00335Z')}}
STEPSSSS this.chuckSize 1000, thread count: 10
03:09:07.095 INFO 9092 --- [ main] c.w.ProductExtractionApplication : Started CarExtractionApplication in 250.186 seconds (JVM running for 251.358)
03:09:07.097 INFO 9092 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: [--spring.output.ansi.enabled=always]
03:09:07.141 INFO 9092 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=car_delta_extraction]] launched with the following parameters: [{-spring.output.ansi.enabled=always, run.id=1}]
03:09:07.159 INFO 9092 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [car-delta-step]
********** Processor **********
********** Processor **********
03:09:26.017 INFO 9092 --- [ main] c.w.l.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results : 18 seconds
03:09:26.019 INFO 9092 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=car_delta_extraction]] completed with the following parameters: [{-spring.output.ansi.enabled=always, run.id=1}] and the following status: [COMPLETED]
03:09:26.066 INFO 9092 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=car_delta_extraction]] launched with the following parameters: [{-spring.output.ansi.enabled=always, run.id=2}]
03:09:26.073 INFO 9092 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [car-delta-step]
********** Processor **********
********** Processor **********
03:09:31.753 INFO 9092 --- [ main] c.w.l.JobCompletionNotificationListener : !!! JOB FINISHED! Time to verify the results : 5 seconds
03:09:31.755 INFO 9092 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=car_delta_extraction]] completed with the following parameters: [{-spring.output.ansi.enabled=always, run.id=2}] and the following status: [COMPLETED]
03:09:31.757 INFO 9092 --- [ Thread-1] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext#d78795: startup date [Thu Jun 06 03:04:57 IST 2019]; root of context hierarchy
03:09:31.759 INFO 9092 --- [ Thread-1] o.s.c.support.DefaultLifecycleProcessor : Stopping beans in phase -2147482648
03:09:31.760 INFO 9092 --- [ Thread-1] ory$ResourceAnnotationApplicationContext : Closing ResourceAnnotationApplicationContext:com.mycar.configuration.CarJobConfiguration
03:09:31.766 INFO 9092 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
03:09:31.767 INFO 9092 --- [ Thread-1] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
03:09:32.042 INFO 9092 --- [ Thread-1] org.mongodb.driver.connection : Closed connection [connectionId{localValue:7, serverValue:510178}] to mongo1:27017 because the pool has been closed.
03:09:32.043 INFO 9092 --- [ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
03:09:32.048 INFO 9092 --- [ Thread-1] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
From the Logs, you can notice that
*********** Processor *********** is printed twice.(Processor is printed twice each time as there are 2 records only)
Mongo Query and the chunck size and threadcount are printed twice.
!!! JOB FINISHED! Time to verify the results : __ is printed twice
Any suggestion would be greatly helpful.
I had this happen recently for a Job created in the method runScenario(). In my Spring Boot App, I had this:
#SpringBootApplication
public class SimulationBatchServiceApplication implements CommandLineRunner {
#Autowired
private JobLauncher jobLauncher;
#Autowired
private Job job;
public static void main(String[] args) {
SpringApplication.run(SimulationBatchServiceApplication.class, args);
}
#Override
public void run(String... args) throws Exception {
JobParameters params = new JobParametersBuilder()
.addString("runScenario", String.valueOf(System.currentTimeMillis()))
.toJobParameters();
jobLauncher.run(job, params);
}
}
runScenario() was also marked with #Bean. Spring therefore picked it up twice -- once to #Autowire the job field, once because I specified "runScenario" in JobParameters. Removing "runScenario" from the JobParameters object did the trick.
#Override
public void run(String... args) throws Exception {
jobLauncher.run(job, new JobParameters());
}
If I required a more dynamic case, I believe I could have removed #Bean and the job field, then specified "runScenario" in JobParameters. That way no autowiring would've occurred, but the job would've been found anyway by looking for the method name.
Perhaps this isn't your issue, but hopefully it provides a clue (or helps a future reader!)

The bean 'metaDataSourceAdvisor', defined in null, could not be registered

I've updated the Spring Boot version from 2.0.3 to 2.1.1 but I'm getting this:
***************************
APPLICATION FAILED TO START
***************************
Description:
The bean 'metaDataSourceAdvisor', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true
I get the error - the problem is that defined in null is not really a good pointer where to look. I've seen this question but I'd actually prefer to keep disallowing overriding ambiguous beans.
Any ideas?
Log output
2019-01-06 07:33:39.282 INFO 29626 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-01-06 07:33:39.282 INFO 29626 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-01-06 07:33:39.912 INFO 29626 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-01-06 07:33:39.997 INFO 29626 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 80ms. Found 23 repository interfaces.
2019-01-06 07:33:39.999 WARN 29626 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'metaDataSourceAdvisor' defined in null: Cannot register bean definition [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] for bean 'metaDataSourceAdvisor': There is already [Root bean: class [org.springframework.security.access.intercept.aopalliance.MethodSecurityMetadataSourceAdvisor]; scope=; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null] bound.
2019-01-06 07:33:40.008 INFO 29626 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-06 07:33:40.010 ERROR 29626 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
Okay, I found the issue myself: I had #EnableGlobalMethodSecurity twice in my project:
#Configuration
#EnableWebSecurity
#EnableGlobalMethodSecurity(prePostEnabled = true) // <--
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
}
and
#SpringBootApplication
#EnableJpaRepositories(basePackages = {"mz.server.spring.repository"})
#EnableGlobalMethodSecurity(prePostEnabled = true, proxyTargetClass = true) // <--
#EntityScan(basePackages = "mz.server.hibernate.model")
#EnableTransactionManagement
#EnableScheduling
public class Application {
}
So that's a nice new Spring Boot feature I'd say.
Just watch out for unwanted duplicate annotations if you see this kind of error.
Expanding on the accepted answer, as per the release notes for Spring Boot 2.1
Bean overriding has been disabled by default to prevent a bean being accidentally overridden. If you are relying on overriding, you will need to set spring.main.allow-bean-definition-overriding to true.
So if you have used #EnableGlobalMethodSecurity more than once in your codebase and these beans are part of the same component scan then this annotation will attempt to create the metaDataSourceAdvisor bean more than once. This will throw an exception during initialization.
This will also apply to other auto configuration annotations that create beans. Make sure to only use their enabling annotations once.
Check if you have missed adding following annotations (whichever applicable)
#EnableJpaRepositories({"com.base.package"})
#EnableMongoRepositories({"com.base.package"})
This worked for me
I tried all these answers. But I noticed that error terminal says spring.main.allow-bean-definition-overriding=true in your properties. Just do it it worked for me.
Can help "clean" and "build" project in Gradle or Maven.

is there any conflict between spring-boot-starter-parent version 2 and spring-security-jwt and spring-security-oauth2

I am trying to fix an issue I am facing with Spring Boot + Java 8 and Hibernate (my original question regard this issue is org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value did not match expected type java.time.LocalDateTime).
Since I read Since 5.2, "the hibernate-java8 module has been merged into hibernate-core and the Java 8 date/time types are now natively supported." from How to persist JSR-310 types with Spring Data JPA?, I tried to update all my Spring Boot dependencies to the most recent.
I mean, my parent pom was before:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/>
</parent>
and I changed to
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/>
</parent>
The purpose to do that was take advantage of "...now natively supported..." as mentioned above assuming it could fix any conflict I could be facing with datetime.
Now I am facing another issue with
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
</dependency>
saying: Project build error: 'dependencies.dependency.version' for org.springframework.security.oauth:spring-security-oauth2:jar is
missing (same for org.springframework.security:spring-security-jwt:jar).
How can I fix that specific issue with org.springframework.security:spring-security-jwt:jar and org.springframework.security.oauth:spring-security-oauth2:jar ?
*** edited, after I change the version as mentioned above, I am getting
:: Spring Boot :: (v1.5.6.RELEASE)
2018-03-26 17:53:10.490 INFO 1161 --- [ restartedMain] br.com.moving.MovingApiApplication : Starting MovingApiApplication on fulls-iMac.home with PID 1161 (/Users/accountname/WSs/ws_servicos_prontos/api-moving/target/classes started by accountname in /Users/accountname/WSs/ws_servicos_prontos/api-moving)
2018-03-26 17:53:10.492 INFO 1161 --- [ restartedMain] br.com.moving.MovingApiApplication : The following profiles are active: ${envspring}
2018-03-26 17:53:10.607 INFO 1161 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#64f45797: startup date [Mon Mar 26 17:53:10 BRT 2018]; root of context hierarchy
2018-03-26 17:53:11.879 INFO 1161 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'commandLineRunner' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=apiSecurityApplication; factoryMethodName=commandLineRunner; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [br/com/moving/ApiSecurityApplication.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=movingApiApplication; factoryMethodName=commandLineRunner; initMethodName=null; destroyMethodName=(inferred); defined in br.com.moving.MovingApiApplication]
2018-03-26 17:53:12.276 INFO 1161 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'httpRequestHandlerAdapter' 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.web.servlet.config.annotation.DelegatingWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]]
2018-03-26 17:53:13.017 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$501c7c5b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.096 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$e8ca4495] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.110 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.115 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler#616c515f' of type [org.springframework.security.oauth2.provider.expression.OAuth2MethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.122 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$d9ee747] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.157 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.212 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'security.oauth2.client-org.springframework.boot.autoconfigure.security.oauth2.OAuth2ClientProperties' of type [org.springframework.boot.autoconfigure.security.oauth2.OAuth2ClientProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.218 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration' of type [org.springframework.boot.autoconfigure.security.oauth2.OAuth2AutoConfiguration$$EnhancerBySpringCGLIB$$766385b] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.254 INFO 1161 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'resourceServerProperties' of type [org.springframework.boot.autoconfigure.security.oauth2.resource.ResourceServerProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-26 17:53:13.831 INFO 1161 --- [ restartedMain] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 9000 (http)
2018-03-26 17:53:13.847 INFO 1161 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-03-26 17:53:13.848 INFO 1161 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.16
2018-03-26 17:53:13.972 INFO 1161 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-03-26 17:53:13.972 INFO 1161 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3368 ms
2018-03-26 17:53:14.201 INFO 1161 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-03-26 17:53:14.203 INFO 1161 --- [ost-startStop-1] .s.DelegatingFilterProxyRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
2018-03-26 17:53:14.203 INFO 1161 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2018-03-26 17:53:14.263 WARN 1161 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through method 'inMemoryDatabaseShutdownExecutor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "${envspring}" are currently active).
2018-03-26 17:53:14.270 INFO 1161 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-03-26 17:53:14.298 INFO 1161 --- [ restartedMain] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2018-03-26 17:53:14.303 ERROR 1161 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Cannot determine embedded database driver class for database type NONE
Action:
If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "${envspring}" are currently active).
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.743 s
[INFO] Finished at: 2018-03-26T17:53:14-03:00
[INFO] ------------------------------------------------------------------------
It sounds strange see v1.5.6.RELEASE in logs while I setup 2.0.0.RELEASE for spring-boot-starter-parent
Spring Boot 2.0 migration guide says that
Functionality from the Spring Security OAuth project is being migrated to core Spring Security. Dependency management is no longer provided for that dependency and Spring Boot 2 provides OAuth 2.0 client support via Spring Security 5.
So you should specify jwt and oauth2 dependencies manually.
<spring-security-oauth2.version>2.3.3.RELEASE</spring-security-oauth2.version>
<spring-security-jwt.version>1.0.9.RELEASE</spring-security-jwt.version>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${spring-security-oauth2.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-jwt</artifactId>
<version>${spring-security-jwt.version}</version>
</dependency>

Error running gradle bootrun

I am trying to do gradle bootRun using IntelliJ, but this error appears:
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':bootRun'.
Process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe'' finished with non-zero exit value 1
In the Console I have this:
2017-06-21 10:13:54.177 INFO 12008 --- [ main] com.nice_system.nicemedia.ApplicationKt : Starting ApplicationKt on DESKTOP-GHI2UHL with PID 12008 (started by Darja Strahlberg in C:\Users\Darja Strahlberg
\code\versuch\nto_niceMediaServer)
2017-06-21 10:13:54.182 INFO 12008 --- [ main] com.nice_system.nicemedia.ApplicationKt : No active profile set, falling back to default profiles: default
2017-06-21 10:13:54.310 INFO 12008 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#5be6e01c: start
up date [Wed Jun 21 10:13:54 CEST 2017]; root of context hierarchy
2017-06-21 10:13:56.234 INFO 12008 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'httpRequestHandlerAdapter' 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.WebMvcAutoConfiguration$Ena
bleWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfigurat
ion$EnableWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframew
ork.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/re
st/webmvc/config/RepositoryRestMvcConfiguration.class]]
2017-06-21 10:13:57.102 INFO 12008 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframe
work.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$dc898557] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2017-06-21 10:13:57.776 INFO 12008 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8081 (http)
2017-06-21 10:13:57.797 INFO 12008 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2017-06-21 10:13:57.800 INFO 12008 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.14
2017-06-21 10:13:58.025 INFO 12008 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2017-06-21 10:13:58.025 INFO 12008 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3719 ms
2017-06-21 10:13:58.319 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Mapping servlet: 'dispatcherServlet' to [/]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2017-06-21 10:13:58.325 INFO 12008 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally u
nnecessary.
2017-06-21 10:14:00.929 ERROR 12008 --- [ main] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
This is my build.gradle file:
plugins {
id "org.jetbrains.kotlin.jvm" version "1.1.2"
id "org.jetbrains.kotlin.plugin.noarg" version "1.1.2"
id "org.jetbrains.kotlin.plugin.jpa" version "1.1.2"
id "org.springframework.boot" version "1.5.3.RELEASE"}
jar {
baseName = 'nicemedia-api'
version = '0.1.0'
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-data-rest"
testCompile "org.springframework.boot:spring-boot-starter-test"
runtime "mysql:mysql-connector-java:6.0.6"
runtime "com.h2database:h2"
}
repositories {
mavenCentral()
}

Disable table recreation in Spring Boot application

I'm trying to build a simple web application using Spring Boot. When I restart the application all database tables are recreated. I tried setting hibernate.hbm2ddl.auto to update or validate but that doesn't help.
This is my configuration:
#ComponentScan
#EnableAutoConfiguration
#EnableHypermediaSupport
#EnableSpringDataWebSupport
public class ApplicationConfig {
#Bean
public DataSource dataSource() {
DriverManagerDataSource datasource = new DriverManagerDataSource();
datasource.setDriverClassName("org.postgresql.Driver");
datasource.setUrl("jdbc:postgresql://localhost/mydatabase");
datasource.setUsername("myusername");
datasource.setPassword("mypassword");
return datasource;
}
#Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan("my.domain.package");
Properties jpaProperties = new Properties();
jpaProperties.setProperty("hibernate.hbm2ddl.auto", "update");
lef.setJpaProperties(jpaProperties);
return lef;
}
#Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(false);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.POSTGRESQL);
return hibernateJpaVendorAdapter;
}
#Bean
public PlatformTransactionManager transactionManager() {
return new JpaTransactionManager();
}
public static void main(String[] args) {
SpringApplication.run(ApplicationConfig.class, args);
}
}
Using --debug I get this (somewhat filtered):
2014-02-23 18:17:30.735 INFO 27716 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#66e43eb8: startup date [Sun Feb 23 18:17:30 CET 2014]; root of context hierarchy
2014-02-23 18:17:31.354 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'pageableResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=pageableResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=pageableResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]]
2014-02-23 18:17:31.355 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'sortResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=sortResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.web.config.HateoasAwareSpringDataWebConfiguration; factoryMethodName=sortResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/web/config/HateoasAwareSpringDataWebConfiguration.class]]
2014-02-23 18:17:31.726 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'viewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=thymeleafConfig; factoryMethodName=viewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [be/**************/******/ThymeleafConfig.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=viewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-02-23 18:17:32.159 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'transactionManager': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=transactionManager; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
2014-02-23 18:17:32.160 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'entityManagerFactory': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=entityManagerFactory; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
2014-02-23 18:17:32.160 INFO 27716 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'jpaVendorAdapter': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=applicationConfig; factoryMethodName=jpaVendorAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class **.**************.******.ApplicationConfig] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; factoryMethodName=jpaVendorAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]]
2014-02-23 18:17:33.031 INFO 27716 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerByCGLIB$$9ca466b9] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2014-02-23 18:17:33.074 INFO 27716 --- [ main] 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-02-23 18:17:33.092 INFO 27716 --- [ main] 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-02-23 18:17:33.102 INFO 27716 --- [ main] 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-02-23 18:17:33.779 INFO 27716 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2014-02-23 18:17:33.779 INFO 27716 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/7.0.42
2014-02-23 18:17:33.909 INFO 27716 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2014-02-23 18:17:33.909 INFO 27716 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3177 ms
2014-02-23 18:17:35.028 INFO 27716 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring FrameworkServlet 'dispatcherServlet'
2014-02-23 18:17:35.028 INFO 27716 --- [ost-startStop-1] o.s.web.servlet.DispatcherServlet : FrameworkServlet 'dispatcherServlet': initialization started
2014-02-23 18:17:35.124 INFO 27716 --- [ost-startStop-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2014-02-23 18:17:35.385 INFO 27716 --- [ost-startStop-1] o.s.j.d.DriverManagerDataSource : Loaded JDBC driver: org.postgresql.Driver
2014-02-23 18:17:35.457 INFO 27716 --- [ost-startStop-1] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2014-02-23 18:17:35.592 INFO 27716 --- [ost-startStop-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
2014-02-23 18:17:35.622 INFO 27716 --- [ost-startStop-1] org.hibernate.Version : HHH000412: Hibernate Core {4.2.1.Final}
2014-02-23 18:17:35.627 INFO 27716 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000205: Loaded properties from resource hibernate.properties: {hibernate.bytecode.use_reflection_optimizer=false, hibernate.hbm2ddl.auto=validate}
2014-02-23 18:17:35.628 INFO 27716 --- [ost-startStop-1] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2014-02-23 18:17:35.655 INFO 27716 --- [ost-startStop-1] org.hibernate.ejb.Ejb3Configuration : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2014-02-23 18:17:35.899 INFO 27716 --- [ost-startStop-1] o.h.s.j.c.i.ConnectionProviderInitiator : HHH000130: Instantiating explicit connection provider: org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider
2014-02-23 18:17:36.256 INFO 27716 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQL82Dialect
2014-02-23 18:17:36.268 INFO 27716 --- [ost-startStop-1] o.h.e.jdbc.internal.LobCreatorBuilder : HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
2014-02-23 18:17:36.284 INFO 27716 --- [ost-startStop-1] o.h.e.t.i.TransactionFactoryInitiator : HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
2014-02-23 18:17:36.292 INFO 27716 --- [ost-startStop-1] o.h.h.i.ast.ASTQueryTranslatorFactory : HHH000397: Using ASTQueryTranslatorFactory
2014-02-23 18:17:36.481 INFO 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000227: Running hbm2ddl schema export
Hibernate: alter table project drop constraint FK_4725849e7c4543e3885bbd3a3a9
2014-02-23 18:17:36.488 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table project drop constraint FK_4725849e7c4543e3885bbd3a3a9
2014-02-23 18:17:36.488 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: constraint "fk_4725849e7c4543e3885bbd3a3a9" of relation "project" does not exist
Hibernate: alter table project drop constraint FK_56d354acd26e412daa99d5584ff
2014-02-23 18:17:36.489 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table project drop constraint FK_56d354acd26e412daa99d5584ff
2014-02-23 18:17:36.489 ERROR 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : ERROR: constraint "fk_56d354acd26e412daa99d5584ff" of relation "project" does not exist
Hibernate: drop table if exists company cascade
Hibernate: drop table if exists project cascade
Hibernate: create table company (id serial not null, name varchar(255), primary key (id))
Hibernate: create table project (id serial not null, reference varchar(255), company int4, primary key (id))
Hibernate: alter table project add constraint FK_4725849e7c4543e3885bbd3a3a9 foreign key (company) references company
2014-02-23 18:17:36.577 INFO 27716 --- [ost-startStop-1] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000230: Schema export complete
Your configuration isn't a #Configuration class.
Next to that I suggest that you use the power of Spring Boot. Which means I would suggest removing everything but the DataSource configuration and simply add an application.properties file with the following properties
spring.jpa.database=POSTGRESQL
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update
This should give you the desired behavior, with less coding.
You could even remove the datasource if you have either commons-dbcp or tomcat-pool in your classpath and adding the following properties
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost/mydatabase
spring.datasource.username=myusername
spring.datasource.password=mypassword
If you are using spring boot, you could do it by configuration over the config file. Hibernate has all this possibilities:
validate (validate the schema)
update (update the schema if are changes)
create (create the schema)
create-drop (create the schema and drop it at the end)
but if you want don't do anything, spring boot add other chance, use as follow:
spring:
jpa:
hibernate:
ddl-auto: none
Your ApplicationConfig is not #Configuration. I imagine that means the Spring Boot autoconfig will also be applied. Can you try adding that?
If you are using a in-memory database then every time you start/stop spring boot application - it will recreate the whole thing unless you mention/configure spring boot to use the database from file system.
update your #Configuration or application.properties for below property
spring.datasource.url=jdbc:h2:file:/Users/user_name/database_file_name
Also check, you should not have spring.datasource.initialization-mode in config.

Resources