Syntax error, insert "EnumBody" to complete ClassBodyDeclarations when using #value - spring-boot

I wrote this class to retrive a property from application.propreties file.
I get the error above on the #value statment. I Tried to set it different ways but nothing helped.
also tried setting it as #componnet.
package com.example.demo;
import org.springframework.context.annotation.Configuration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import javax.management.loading.PrivateMLet;
import org.springframework.beans.factory.annotation.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.*;
#Configuration
public class ApplicationConfiguration {
#Value("${spring.datasource.url");
private String JdbcUrl;
#Value("${spring.datasource.user:}");
private String JdbcUser;
#Value("${spring.datasource.password:}");
private String JdbcPassword;
public String getJdbcUrl() {
return JdbcUrl;
}
public String getJdbcUser() {
return JdbcUser;
}
public String getJdbcPassword() {
return JdbcPassword;
}
}
the Erorr I get is:
2020-12-05 11:11:30.077 INFO 660 --- [ main] c.e.demo.AccessPostgresApplication : Starting AccessPostgresApplication on user-PC with PID 660 (C:\Users\user\Documents\mytrips\target\classes started by user in C:\Users\user\Documents\mytrips)
2020-12-05 11:11:30.080 INFO 660 --- [ main] c.e.demo.AccessPostgresApplication : The following profiles are active: dev
2020-12-05 11:11:31.838 INFO 660 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-12-05 11:11:31.838 INFO 660 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.38]
2020-12-05 11:11:32.008 INFO 660 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded
WebApplicationContext
2020-12-05 11:11:32.124 INFO 660 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2020-12-05 11:11:32.551 INFO 660 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2020-12-05 11:11:33.153 INFO 660 --- [ task-1] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-12-05 11:11:33.223 INFO 660 --- [ task-1] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.21.Final
2020-12-05 11:11:33.418 INFO 660 --- [ task-1] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-12-05 11:11:33.578 INFO 660 --- [ task-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2020-12-05 11:11:34.580 INFO 660 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform
implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
Exception in thread "task-2" java.lang.IllegalStateException: EntityManagerFactory is closed
at org.hibernate.internal.SessionFactoryImpl.validateNotClosed(SessionFactoryImpl.java:509)
2020-12-05 11:11:34.606 INFO 660 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
at org.hibernate.internal.SessionFactoryImpl.getProperties(SessionFactoryImpl.java:503)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.findDataSource(DataSourceInitializedPublisher.java:105)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:97)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
2020-12-05 11:11:34.614 INFO 660 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2020-12-05 11:11:34.616 INFO 660 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-12-05 11:11:34.641 ERROR 660 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applicationConfiguration' defined in file [C:\Users\user\Documents\mytrips\target\classes\com\example\demo\ApplicationConfiguration.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.demo.ApplicationConfiguration$$EnhancerBySpringCGLIB$$5e10e388]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problems:
Syntax error, insert "enum Identifier" to complete EnumHeaderName
Syntax error, insert "EnumBody" to complete ClassBodyDeclarations
Syntax error, insert "enum Identifier" to complete EnumHeaderName
Syntax error, insert "EnumBody" to complete EnumDeclaration
Syntax error, insert "enum Identifier" to complete EnumHeaderName
Syntax error, insert "EnumBody" to complete EnumDeclaration
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1318) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1213) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.9.RELEASE.jar:5.2.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.3.4.RELEASE.jar:2.3.4.RELEASE]
at com.example.demo.AccessPostgresApplication.main(AccessPostgresApplication.java:11) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
jsdkfn kljsfn lkflksd ;lskjf ;lskjf ;lkfj s;lkfj ;lskjdf ;lkj ;lskdjf nvm,fnbmdnb ,mfnb ,mdsn

You can not use final with #Value in spring. If you use final with a field in a class then you must initialize the field and after initialization the value can not be changed.
But #Value workes differently, spring will populate the value at runtime, so if there is a final identifier, spring will not be able to populate the value with the value of the property.
In your case, you are using final but you are not initializing the value, that's why you are getting an exception. If you can either remove the final or init the value with something to remove the exception. If you remove the final spring will be able to populate the value. If you init the value with something, then the value will not be changed in you application.

Found the issue. there was a ';' at the end of the #value statment

Related

Illegal use of #Table in a subclass of a SINGLE_TABLE hierarchy

I'm a newbie in Spring. I try to create a project with SOLID techniques but was faced with that error. Inheritance does not work in my application. Why inheritance does not work properly? Is inheritance allowed in Spring?
Text of Error:
2021-06-23 23:54:08.928 INFO 12984 --- [ restartedMain] hrms.northwind.NorthwindApplication : Starting NorthwindApplication using Java 15.0.2 on DESKTOP-87K40S0 with PID 12984 (C:\Users\90553\Desktop\Eclipse Projects\HRMS Project\target\classes started by 90553 in C:\Users\90553\Desktop\Eclipse Projects\HRMS Project)
2021-06-23 23:54:08.929 INFO 12984 --- [ restartedMain] hrms.northwind.NorthwindApplication : No active profile set, falling back to default profiles: default
2021-06-23 23:54:08.978 INFO 12984 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-06-23 23:54:08.978 INFO 12984 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-06-23 23:54:09.465 INFO 12984 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2021-06-23 23:54:09.512 INFO 12984 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 40 ms. Found 2 JPA repository interfaces.
2021-06-23 23:54:10.040 INFO 12984 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2021-06-23 23:54:10.052 INFO 12984 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-06-23 23:54:10.052 INFO 12984 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.46]
2021-06-23 23:54:10.130 INFO 12984 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-06-23 23:54:10.130 INFO 12984 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1152 ms
2021-06-23 23:54:10.203 INFO 12984 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2021-06-23 23:54:10.367 INFO 12984 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2021-06-23 23:54:10.458 INFO 12984 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-06-23 23:54:10.502 INFO 12984 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.4.32.Final
2021-06-23 23:54:10.619 INFO 12984 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2021-06-23 23:54:10.721 INFO 12984 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
2021-06-23 23:54:11.047 WARN 12984 --- [ restartedMain] org.hibernate.cfg.AnnotationBinder : HHH000139: Illegal use of #Table in a subclass of a SINGLE_TABLE hierarchy: hrms.northwind.entities.concretes.Employer
2021-06-23 23:54:11.049 WARN 12984 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.ClassCastException: class org.hibernate.mapping.SingleTableSubclass cannot be cast to class org.hibernate.mapping.RootClass (org.hibernate.mapping.SingleTableSubclass and org.hibernate.mapping.RootClass are in unnamed module of loader 'app')
2021-06-23 23:54:11.050 INFO 12984 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2021-06-23 23:54:11.053 INFO 12984 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2021-06-23 23:54:11.057 INFO 12984 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-06-23 23:54:11.066 INFO 12984 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-06-23 23:54:11.084 ERROR 12984 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
Employer Class:
package hrms.northwind.entities.concretes;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
#Entity(name="Employers")
#Table(name="Employers")
#Data
public class Employer extends Person {
#Id
#GeneratedValue
#Column(name="employer_id")
private int employerId;
#Column(name="company_name")
private String company_name;
#Column(name="website")
private String website;
#Column(name="phone_number")
private String phone_number;
#Column(name="password")
private String password;
public Employer(int personId, String name, String surname, String email, int employerId, String company_name, String website,
String phone_number, String password) {
super(personId, name, surname, email);
this.employerId = employerId;
this.company_name = company_name;
this.website = website;
this.phone_number = phone_number;
this.password = password;
}
}
Employer Dao:
package hrms.northwind.dataAccess.abstracts;
import org.springframework.data.jpa.repository.JpaRepository;
import hrms.northwind.entities.concretes.Employer;
public interface EmployerDao extends JpaRepository<Employer,Integer>{
}
Employer Service:
package hrms.northwind.business.abstracts;
import java.util.List;
import org.springframework.stereotype.Service;
import hrms.northwind.entities.concretes.Employer;
#Service
public interface EmployerService {
List<Employer> getAll();
}
Employer Controller:
package hrms.northwind.api.controllers;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import hrms.northwind.business.abstracts.EmployerService;
import hrms.northwind.entities.concretes.Employer;
#RestController
#RequestMapping("/api/employers")
public class EmployerController {
private EmployerService employerService;
#Autowired
public EmployerController(EmployerService employerService) {
super();
this.employerService = employerService;
}
#GetMapping("/getall")
public List<Employer> getAll(){
return this.employerService.getAll();
}
}
Employer Table:
Employer Table
Any help?
Maybe is late for this answer
I think the problem comes from #Table. That annotation is optional when you want to specify an entity.
You could find better documented answer here
You can add this to your Employer class.
#Inheritance(strategy = InheritanceType.JOINED)
#JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
#PrimaryKeyJoinColumn(name="employer_id",referencedColumnName = "person_id")

How to configure a Spring Boot project correctly to work with Quartz and MySQL?

What I did is:
Created a Spring Boot (v2.1.8) Gradle project with Web, JPA, MySQL and Quartz as dependencies.
Then Added following properties on application.properties file
spring.application.name=QuartzTestWithMySQL
server.port=8081
## Data source
#docker run -d --rm -p 3306:3306 --name=mysql-docker -e MYSQL_ROOT_PASSWORD=root -e MYSQL_USER=test -e MYSQL_PASSWORD=test -e MYSQL_DATABASE=testDB mysql:latest
spring.datasource.name = myDS
spring.datasource.url=jdbc:mysql://localhost:3306/testDB
spring.datasource.username=test
spring.datasource.password=test
## Hibernate Properties
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = create-drop
## QuartzProperties
#spring.quartz.job-store-type=memory
spring.quartz.job-store-type=jdbc
spring.quartz.properties.org.quartz.threadPool.threadCount=5
#spring.quartz.jdbc.initialize-schema=always
#spring.quartz.properties.org.quartz.scheduler.instanceName = MyScheduler
#spring.quartz.properties.org.quartz.threadPool.threadCount = 3
#spring.quartz.properties.org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
spring.quartz.properties.org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
#spring.quartz.properties.org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
spring.quartz.properties.org.quartz.jobStore.tablePrefix = QRTZ_
spring.quartz.properties.org.quartz.jobStore.dataSource = myDS
build.gradle file is:
plugins {
id 'org.springframework.boot' version '2.1.8.RELEASE'
id 'io.spring.dependency-management' version '1.0.8.RELEASE'
id 'java'
}
group = 'com.onssoftware'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-quartz'
implementation 'org.springframework.boot:spring-boot-starter-web'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
Then created following job class:
public class Bismillah implements Job {
#Override
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("Assalamu Alaikum");
}
}
Then created a controller like:
#RestController
public class SchedulerTestController {
#Autowired
private Scheduler scheduler;
#GetMapping("/scheduler")
public void testScheduler() throws SchedulerException {
// Grab the Scheduler instance from the Factory
//Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
// and start it off
//scheduler.start();
JobDetail job = JobBuilder.newJob(Bismillah.class)
.withIdentity("job1", "group1")
.storeDurably()
.withDescription("Bismillah hir rahmanir rahim")
.build();
CronTrigger cronTrigger = TriggerBuilder.newTrigger()
.withIdentity("trigger1", "group1")
.withSchedule(CronScheduleBuilder.cronSchedule("* * 11 * * ?"))
.forJob("job1", "group1")
.build();
scheduler.scheduleJob(job, cronTrigger);
}
}
Then I call from browser following url:
http://localhost:8081/scheduler
to schedule the job.
What I am getting is:
2019-09-18 12:55:31.445 INFO 10507 --- [ main] c.o.Q.QuartzTestWithMySqlApplication : No active profile set, falling back to default profiles: default
2019-09-18 12:55:32.326 INFO 10507 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-09-18 12:55:32.359 INFO 10507 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 18ms. Found 0 repository interfaces.
2019-09-18 12:55:32.810 INFO 10507 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$7395a7a2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-09-18 12:55:33.198 INFO 10507 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8081 (http)
2019-09-18 12:55:33.235 INFO 10507 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-09-18 12:55:33.235 INFO 10507 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24]
2019-09-18 12:55:33.344 INFO 10507 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-09-18 12:55:33.344 INFO 10507 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1841 ms
2019-09-18 12:55:33.545 INFO 10507 --- [ main] com.zaxxer.hikari.HikariDataSource : myDS - Starting...
2019-09-18 12:55:34.179 INFO 10507 --- [ main] com.zaxxer.hikari.HikariDataSource : myDS - Start completed.
2019-09-18 12:55:34.269 INFO 10507 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-09-18 12:55:34.344 INFO 10507 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.11.Final}
2019-09-18 12:55:34.345 INFO 10507 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-09-18 12:55:34.502 INFO 10507 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-09-18 12:55:34.682 INFO 10507 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2019-09-18 12:55:34.763 INFO 10507 --- [ main] o.h.e.j.e.i.LobCreatorBuilderImpl : HHH000421: Disabling contextual LOB creation as hibernate.jdbc.lob.non_contextual_creation is true
2019-09-18 12:55:35.033 INFO 10507 --- [ main] o.h.t.schema.internal.SchemaCreatorImpl : HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl#2007435e'
2019-09-18 12:55:35.039 INFO 10507 --- [ main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-09-18 12:55:35.596 INFO 10507 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-09-18 12:55:35.764 WARN 10507 --- [ main] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-09-18 12:55:36.509 WARN 10507 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration$JdbcStoreTypeConfiguration$QuartzSchedulerDependencyConfiguration': Unexpected exception during bean creation; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
2019-09-18 12:55:36.518 INFO 10507 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2019-09-18 12:55:36.520 INFO 10507 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-09-18 12:55:36.522 INFO 10507 --- [ main] .SchemaDropperImpl$DelayedDropActionImpl : HHH000477: Starting delayed evictData of schema as part of SessionFactory shut-down'
2019-09-18 12:55:36.541 INFO 10507 --- [ main] com.zaxxer.hikari.HikariDataSource : myDS - Shutdown initiated...
2019-09-18 12:55:36.553 INFO 10507 --- [ main] com.zaxxer.hikari.HikariDataSource : myDS - Shutdown completed.
2019-09-18 12:55:36.561 INFO 10507 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-09-18 12:55:36.592 INFO 10507 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-09-18 12:55:36.613 ERROR 10507 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration$JdbcStoreTypeConfiguration$QuartzSchedulerDependencyConfiguration': Unexpected exception during bean creation; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:528) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.8.RELEASE.jar:2.1.8.RELEASE]
at com.onssoftware.QuartzTestWithMySQL.QuartzTestWithMySqlApplication.main(QuartzTestWithMySqlApplication.java:10) [classes/:na]
Caused by: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724) ~[na:1.8.0_201]
at sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531) ~[na:1.8.0_201]
at sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355) ~[na:1.8.0_201]
at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286) ~[na:1.8.0_201]
at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) ~[na:1.8.0_201]
at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) ~[na:1.8.0_201]
at java.lang.reflect.Executable.declaredAnnotations(Executable.java:599) ~[na:1.8.0_201]
at java.lang.reflect.Executable.declaredAnnotations(Executable.java:597) ~[na:1.8.0_201]
at java.lang.reflect.Executable.getAnnotation(Executable.java:570) ~[na:1.8.0_201]
at java.lang.reflect.Method.getAnnotation(Method.java:622) ~[na:1.8.0_201]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.lambda$determineCandidateConstructors$0(AutowiredAnnotationBeanPostProcessor.java:249) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:410) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:417) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:389) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:248) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1269) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1184) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 14 common frames omitted
Process finished with exit code 1
I think your error related to the following issue
/spring-boot/issues/18153
You could try to downgrade spring-boot to 2.1.7.RELEASE:
plugins {
id 'org.springframework.boot' version '2.1.7.RELEASE'
...
}

Flyway not finding migrations when run from IntelliJ when using Gradle

When I run my Spring Boot Kotlin application that uses Flyway from the command line, it seems to work, but from IntelliJ it fails. I created a minimal sample project that replicates the problem: https://github.com/pupeno/notflying
The error I get from IntelliJ is about the migrations not being found:
Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:184) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:149) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a.CGLIB$flyway$0(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a$$FastClassBySpringCGLIB$$5b3da70f.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$ffc78d0a.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 27 common frames omitted
The migrations are there and correctly named as far as I can see:
PS C:\Users\pupeno\Temporary\notflying> dir .\src\main\resources\db\migration\
Directory: C:\Users\pupeno\Temporary\notflying\src\main\resources\db\migration
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2019-08-26 08:32 718 V0001__create_countries_table.sql
PS C:\Users\pupeno\Temporary\notflying>
The IntelliJ configuration for running it looks like this:
I added:
logging.level.org.flywaydb=DEBUG
to application.properties and the full output of trying to start the application from IntelliJ looks like this:
"C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\jbr\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\lib\idea_rt.jar=50536:C:\Program Files\JetBrains\IntelliJ IDEA 2019.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\pupeno\Temporary\notflying\build\classes\java\main;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-data-jpa\2.1.7.RELEASE\5e4a5d5442f32f5e12b36674a620ec57b0b66c6e\spring-boot-starter-data-jpa-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-thymeleaf\2.1.7.RELEASE\cf9547e20aa6a32c0b0f53400db6eecfab660f86\spring-boot-starter-thymeleaf-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-web\2.1.7.RELEASE\fa43baf40bde3ecdb93ac9c545dd39f82ab29c35\spring-boot-starter-web-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-kotlin\2.9.9\446b0567b26965cf7db859ba48a73ab30b4016b7\jackson-module-kotlin-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-devtools\2.1.7.RELEASE\5a846c6e9ab67a4cbf7c4f22bc13bcab188198f9\spring-boot-devtools-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.flywaydb\flyway-core\5.2.4\50a92d39554615bd4ff56d148a359b20dc17f655\flyway-core-5.2.4.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.2.71\7512db3b3182753bd2e48ce8d345abbadc40fe6b\kotlin-reflect-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk8\1.2.71\5470d1f752cd342edb77e1062bac07e838d2cea4\kotlin-stdlib-jdk8-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-aop\2.1.7.RELEASE\4577d056af1f823bb7730c99f43c3268dd697310\spring-boot-starter-aop-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-jdbc\2.1.7.RELEASE\3ea97a134b44a886ff529215e7bec04bfd93fa5b\spring-boot-starter-jdbc-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.transaction\javax.transaction-api\1.3\e006adf5cf3cca2181d16bd640ecb80148ec0fce\javax.transaction-api-1.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.xml.bind\jaxb-api\2.3.1\8531ad5ac454cc2deb9d4d32c40c4d7451939b5d\jaxb-api-2.3.1.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.h2database\h2\1.4.199\7bf08152984ed8859740ae3f97fae6c72771ae45\h2-1.4.199.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.3.10.Final\e608b854325005edbf43cb2b6041fdafd3f2eb57\hibernate-core-5.3.10.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.1.10.RELEASE\12639406aa28c3a5195a1a4c9077fe562f54bc31\spring-data-jpa-2.1.10.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aspects\5.1.9.RELEASE\a8aec853c345ed54a99627cee9f755ce7dbb734\spring-aspects-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-json\2.1.7.RELEASE\9c12f046a7c4ae110d89163a491ad0d7cf036e79\spring-boot-starter-json-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter\2.1.7.RELEASE\e23f4e9460e0e2220b444e40fc7fd6e95f66e0fe\spring-boot-starter-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf-spring5\3.0.11.RELEASE\de7bf0adf13b5e9c4811f95edf18279da193c0c6\thymeleaf-spring5-3.0.11.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf.extras\thymeleaf-extras-java8time\3.0.4.RELEASE\36e7175ddce36c486fff4578b5af7bb32f54f5df\thymeleaf-extras-java8time-3.0.4.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-tomcat\2.1.7.RELEASE\11f2a86aefefba72a4efe5ff18f4165a4b4e78b\spring-boot-starter-tomcat-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate.validator\hibernate-validator\6.0.17.Final\af73055fc4a103ab347c56e7da5a143d68a0170\hibernate-validator-6.0.17.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-webmvc\5.1.9.RELEASE\b9d4a2140488f0e6f9aa231e7938ae18da77b637\spring-webmvc-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-web\5.1.9.RELEASE\9fe4390420fdd0b63dc4ed90d9027dafa9f74f80\spring-web-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.9\4b04126963103216c9c43b0f34bbc36315654204\jackson-datatype-jdk8-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.9\a33df137557793b0404a486888dbe049f7abeeeb\jackson-datatype-jsr310-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.9\a92facb55a2538e7b2fe14294570a18b823ad431\jackson-module-parameter-names-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.9\d6eb9817d9c7289a91f043ac5ee02a6b3cc86238\jackson-databind-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-jdk7\1.2.71\4ce93f539e2133f172f1167291a911f83400a5d0\kotlin-stdlib-jdk7-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib\1.2.71\d9717625bb3c731561251f8dd2c67a1011d6764c\kotlin-stdlib-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-autoconfigure\2.1.7.RELEASE\2c9d3e2c6ea3cb435e99e2973009636b62a9d816\spring-boot-autoconfigure-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot\2.1.7.RELEASE\1599a2ad1fc6d36dbfc2a7c0dd5dab3a0bb27c61\spring-boot-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-context\5.1.9.RELEASE\c37f8fe15a5ae4ea1f351bd46167fd492a84eefa\spring-context-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-aop\5.1.9.RELEASE\bc2312ffad02251b9d472e4a7c0e472a58f50fbf\spring-aop-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.aspectj\aspectjweaver\1.9.4\9205229878f3d62fbd3a32a0fb6be2d6ad8589a9\aspectjweaver-1.9.4.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.zaxxer\HikariCP\3.2.0\6c66db1c636ee90beb4c65fe34abd8ba9396bca6\HikariCP-3.2.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-orm\5.1.9.RELEASE\220169d217f7114706141fc0afba425a5b368dce\spring-orm-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.1.9.RELEASE\3fd70356ba8d7c00c4081c1a207766352624414e\spring-jdbc-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.activation\javax.activation-api\1.2.0\85262acf3ca9816f9537ca47d5adeabaead7cb16\javax.activation-api-1.2.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.hibernate.common\hibernate-commons-annotations\5.0.4.Final\965a18fdf939ee75e41f7918532d37b3a8350535\hibernate-commons-annotations-5.0.4.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.2.Final\3789d00e859632e6c6206adc0c71625559e6e3b0\jboss-logging-3.3.2.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.persistence\javax.persistence-api\2.2\25665ac8c0b62f50e6488173233239120fc52c96\javax.persistence-api-2.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.javassist\javassist\3.23.2-GA\c5afe660a95e87ceb518e4f5cf02f5c56b547683\javassist-3.23.2-GA.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\net.bytebuddy\byte-buddy\1.9.16\e7d63009be7b87ff1f15b72e5b8c59c897a8d8bd\byte-buddy-1.9.16.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\antlr\antlr\2.7.7\83cd2cd674a217ade95a4bb83a8a14f351f48bd0\antlr-2.7.7.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jboss\jandex\2.0.5.Final\7060f67764565b9ee9d467e3ed0cb8a9c601b23a\jandex-2.0.5.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml\classmate\1.4.0\291658ac2ce2476256c7115943652c0accb5c857\classmate-1.4.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.dom4j\dom4j\2.1.1\3dce5dbb3571aa820c677fadd8349bfa8f00c199\dom4j-2.1.1.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.1.10.RELEASE\c73a76070181b59b19df6893e1ca729263a69b47\spring-data-commons-2.1.10.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-tx\5.1.9.RELEASE\a9125e2c8eeb193030f3972c6293616943c55ef2\spring-tx-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-beans\5.1.9.RELEASE\5a03b3983108d73978aec2fa3e681aedad6782c\spring-beans-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-expression\5.1.9.RELEASE\db3a2468c1b7d697ec3b3ec6e5652dc282994fe3\spring-expression-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-core\5.1.9.RELEASE\dc3815439579b4fa0c19970e6b8e5d774af8d988\spring-core-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.thymeleaf\thymeleaf\3.0.11.RELEASE\628ebb91f520053d4120b7b18bf78ff295d57461\thymeleaf-3.0.11.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework.boot\spring-boot-starter-logging\2.1.7.RELEASE\6e829f739992a7f368c0af44a08ed89ad2a1972f\spring-boot-starter-logging-2.1.7.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-classic\1.2.3\7c4f3c474fb2c041d8028740440937705ebb473a\logback-classic-1.2.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-to-slf4j\2.11.2\6d37bf7b046c0ce2669f26b99365a2cfa45c4c18\log4j-to-slf4j-2.11.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.slf4j\jul-to-slf4j\1.7.26\8031352b2bb0a49e67818bf04c027aa92e645d5c\jul-to-slf4j-1.7.26.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.slf4j\slf4j-api\1.7.26\77100a62c2e6f04b53977b9f541044d7d722693d\slf4j-api-1.7.26.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.annotation\javax.annotation-api\1.3.2\934c04d3cfef185a8008e7bf34331b79730a9d43\javax.annotation-api-1.3.2.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-websocket\9.0.22\45974d3443cc15ad9d10239d762d5e15759e6364\tomcat-embed-websocket-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-core\9.0.22\79f39903498b28adacb18fe2ea046edd306295a6\tomcat-embed-core-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.tomcat.embed\tomcat-embed-el\9.0.22\4da4b778b635a7e78ca7cd7288253e2e47b88a9f\tomcat-embed-el-9.0.22.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\javax.validation\validation-api\2.0.1.Final\cb855558e6271b1b32e716d24cb85c7f583ce09e\validation-api-2.0.1.Final.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.9\bfff5af9fb8347d26bbb7959cb9b4fe9a2b0ca5e\jackson-core-2.9.9.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-stdlib-common\1.2.71\ba18ca1aa0e40eb6f1865b324af2f4cbb691c1ec\kotlin-stdlib-common-1.2.71.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.yaml\snakeyaml\1.23\ec62d74fe50689c28c0ff5b35d3aebcaa8b5be68\snakeyaml-1.23.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.jetbrains\annotations\13.0\919f0dfe192fb4e063e7dacadee7f8bb9a2672a9\annotations-13.0.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.1.9.RELEASE\7c372790c999777d20f364960cf557dd74f890cf\spring-jcl-5.1.9.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.attoparser\attoparser\2.0.5.RELEASE\a93ad36df9560de3a5312c1d14f69d938099fa64\attoparser-2.0.5.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.unbescape\unbescape\1.1.6.RELEASE\7b90360afb2b860e09e8347112800d12c12b2a13\unbescape-1.1.6.RELEASE.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\ch.qos.logback\logback-core\1.2.3\864344400c3d4d92dfeb0a305dc87d953677c03c\logback-core-1.2.3.jar;C:\Users\pupeno\.gradle\caches\modules-2\files-2.1\org.apache.logging.log4j\log4j-api\2.11.2\f5e9a2ffca496057d6891a3de65128efc636e26e\log4j-api-2.11.2.jar tech.flexpoint.notflying.NotflyingApplicationKt
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)
2019-08-26 10:36:00.478 INFO 7132 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Starting NotflyingApplicationKt on Utopia-Planitia with PID 7132 (C:\Users\pupeno\Temporary\notflying\build\classes\java\main started by pupeno in C:\Users\pupeno\Temporary\notflying)
2019-08-26 10:36:00.484 INFO 7132 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : No active profile set, falling back to default profiles: default
2019-08-26 10:36:00.549 INFO 7132 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-08-26 10:36:00.550 INFO 7132 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-08-26 10:36:01.616 INFO 7132 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-08-26 10:36:01.641 INFO 7132 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces.
2019-08-26 10:36:02.113 INFO 7132 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$e16cf649] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-26 10:36:02.433 INFO 7132 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-26 10:36:02.460 INFO 7132 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-26 10:36:02.460 INFO 7132 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.22]
2019-08-26 10:36:02.696 INFO 7132 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-26 10:36:02.696 INFO 7132 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2146 ms
2019-08-26 10:36:02.831 WARN 7132 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
2019-08-26 10:36:02.834 INFO 7132 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-08-26 10:36:02.848 INFO 7132 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-08-26 10:36:02.864 ERROR 7132 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:456) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1321) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1160) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:743) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:390) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1214) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1203) ~[spring-boot-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at tech.flexpoint.notflying.NotflyingApplicationKt.main(NotflyingApplication.kt:13) ~[main/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.1.7.RELEASE.jar:2.1.7.RELEASE]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 26 common frames omitted
Caused by: java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
at org.springframework.util.Assert.state(Assert.java:94) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.checkLocationExists(FlywayAutoConfiguration.java:184) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:149) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9.CGLIB$flyway$1(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9$$FastClassBySpringCGLIB$$a2f39a48.invoke(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE]
at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration$$EnhancerBySpringCGLIB$$616ac3e9.flyway(<generated>) ~[spring-boot-autoconfigure-2.1.7.RELEASE.jar:2.1.7.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE]
... 27 common frames omitted
Process finished with exit code 0
I've tried this, with the same result, both with the JDK provided by IntelliJ (version 11 I think) as well as Oracle JDK 11:
PS C:\Users\pupeno\Temporary\notflying> java --version
java 12.0.2 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)
When I trigger a build in IntelliJ, I get some warning (not sure if relevant):
I re-created the project with Maven and it seems to work out of the box, with no issues. So, I'd say, the problem seems to be in how IntelliJ imports Gradle projects.
Perfectly work on my machine
Probably migrations not copied to build/resources/main/db directory
Try next:
Delete build directory
Invalidate idea cache link
Reimport gradle link
If that doesn't help replace Build to gradle build in configuration settings:
Also maybe gradle not have access to read migration file or parent directory. Check permissions in file system or try clone github repository to another folder.
Looks like Intellij might have created the directory as
src/main/resources/db.migration
with the files in a directory called db.migration, instead of
src/main/resources/db/migration
with the files in a directory called migration.
My try, which succeeded:
Rename to a name that isn't your name in mind.
Run gradle clean and start test.
Expect: No migrations found.
Rename it again to your desired name. Run the test again.
Expect: Migrations found!
Its definitely a bug in IntelliJ/Gradle where it doesn't detect resources to import when there is no builds exists before its compilation. Making changes to the script refreshes its state, and automatically imports the resource afterwards.
Working fine for me:
$ ./gradlew bootRun
./gradlew: 39: cd: can't cd to "./
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.7.RELEASE)
2019-08-26 08:21:36.837 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Starting NotflyingApplicationKt on LAP025 with PID 1789 (/mnt/c/Users/bleug/Desktop/notflying/build/classes/kotlin/main started by bleug in /mnt/c/Users/bleug/Desktop/notflying)
2019-08-26 08:21:36.846 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : No active profile set, falling back to default profiles: default
2019-08-26 08:21:37.116 INFO 1789 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2019-08-26 08:21:37.116 INFO 1789 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2019-08-26 08:21:40.958 INFO 1789 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode.
2019-08-26 08:21:41.124 INFO 1789 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 106ms. Found 0 repository interfaces.
2019-08-26 08:21:42.578 INFO 1789 --- [ restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$6414adf5] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-08-26 08:21:43.698 INFO 1789 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2019-08-26 08:21:43.781 INFO 1789 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-08-26 08:21:43.782 INFO 1789 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.22]
2019-08-26 08:21:44.196 INFO 1789 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-08-26 08:21:44.196 INFO 1789 --- [ restartedMain] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 7080 ms
2019-08-26 08:21:44.735 INFO 1789 --- [ restartedMain] o.f.c.internal.license.VersionPrinter : Flyway Community Edition 5.2.4 by Boxfuse
2019-08-26 08:21:44.765 INFO 1789 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2019-08-26 08:21:45.433 INFO 1789 --- [ restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2019-08-26 08:21:45.460 INFO 1789 --- [ restartedMain] o.f.c.internal.database.DatabaseFactory : Database: jdbc:h2:mem:testdb (H2 1.4)
2019-08-26 08:21:45.607 WARN 1789 --- [ restartedMain] o.f.c.internal.database.base.Database : Flyway upgrade recommended: H2 1.4.199 is newer than this version of Flyway and support has not been tested.
2019-08-26 08:21:45.860 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbValidate : Successfully validated 1 migration (execution time 00:00.086s)
2019-08-26 08:21:45.893 INFO 1789 --- [ restartedMain] o.f.c.i.s.JdbcTableSchemaHistory : Creating Schema History table: "PUBLIC"."flyway_schema_history"
2019-08-26 08:21:45.976 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Current version of schema "PUBLIC": << Empty Schema >>
2019-08-26 08:21:45.993 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Migrating schema "PUBLIC" to version 0001 - create countries table
2019-08-26 08:21:46.051 INFO 1789 --- [ restartedMain] o.f.core.internal.command.DbMigrate : Successfully applied 1 migration to schema "PUBLIC" (execution time 00:00.165s)
2019-08-26 08:21:46.616 INFO 1789 --- [ restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2019-08-26 08:21:46.939 INFO 1789 --- [ restartedMain] org.hibernate.Version : HHH000412: Hibernate Core {5.3.10.Final}
2019-08-26 08:21:46.944 INFO 1789 --- [ restartedMain] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2019-08-26 08:21:47.555 INFO 1789 --- [ restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.0.4.Final}
2019-08-26 08:21:48.169 INFO 1789 --- [ restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.H2Dialect
2019-08-26 08:21:48.963 INFO 1789 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-08-26 08:21:49.033 INFO 1789 --- [ restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2019-08-26 08:21:49.920 INFO 1789 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-08-26 08:21:50.137 WARN 1789 --- [ restartedMain] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2019-08-26 08:21:50.476 WARN 1789 --- [ restartedMain] ion$DefaultTemplateResolverConfiguration : Cannot find template location: classpath:/templates/ (please add some templates or check your Thymeleaf configuration)
2019-08-26 08:21:51.143 INFO 1789 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2019-08-26 08:21:51.153 INFO 1789 --- [ restartedMain] t.f.notflying.NotflyingApplicationKt : Started NotflyingApplicationKt in 15.774 seconds (JVM running for 17.982)
If you enable debug logger by adding this line in application.properties:
logging.level.org.flywaydb=DEBUG
It will show you the exact path :
2019-08-26 08:30:31.661 DEBUG 1996 --- [ restartedMain] o.f.c.i.s.classpath.ClassPathScanner : Scanning URL: file:/mnt/c/Users/bleug/Desktop/notflying/build/resources/main/db/migration
Try to run it from a path with no space.
Edit:
Use gradle to run the project
It might be a long shot but still:
Can you try editing the path provided to flyway scripts to use backslash instead of forward slash?
flyway.locations=classpath:db\migration
or even
flyway.locations=filesystem=C:\Users\pupeno\Temporary\notflying\src\main\resources\db\migration
I've noticed that you are running your application in a Windows environment. It might be that Gradle does some magic regarding the default values but IntelliJ doesn't.
The answer by Nick was correct that migrations weren't being copied into the build/resources folder.
I work around this by adding the following to my script:
tasks.withType(org.flywaydb.gradle.task.AbstractFlywayTask) {
dependsOn processResources
}
Not sure why the Flyway gradle plugin doesn't do that.

Spring Session Boot Error - No session repository could be auto-configured, check your configuration (session store type is 'jdbc')

I am trying to create a simple Spring Boot Session project. It's the basic setup from Spring Initializr. I am getting following errors:
2018-06-20 12:59:24.318 INFO 8108 --- [ main] c.j.s.SpringSessionExampleApplication : Starting SpringSessionExampleApplication on pankaj with PID 8108 (/Users/pankaj/Documents/workspace-sts-3.9.4.RELEASE/Spring-Session-Example/target/classes started by pankaj in /Users/pankaj/Documents/workspace-sts-3.9.4.RELEASE/Spring-Session-Example)
2018-06-20 12:59:24.329 INFO 8108 --- [ main] c.j.s.SpringSessionExampleApplication : No active profile set, falling back to default profiles: default
2018-06-20 12:59:24.372 INFO 8108 --- [ main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#39de3d36: startup date [Wed Jun 20 12:59:24 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 (file:/Users/pankaj/.m2/repository/org/springframework/spring-core/5.0.7.RELEASE/spring-core-5.0.7.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-06-20 12:59:25.208 INFO 8108 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2018-06-20 12:59:25.226 INFO 8108 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2018-06-20 12:59:25.226 INFO 8108 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-06-20 12:59:25.230 INFO 8108 --- [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/pankaj/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.]
2018-06-20 12:59:25.297 INFO 8108 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2018-06-20 12:59:25.297 INFO 8108 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 931 ms
2018-06-20 12:59:25.407 INFO 8108 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean : Servlet dispatcherServlet mapped to [/]
2018-06-20 12:59:25.411 INFO 8108 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-06-20 12:59:25.411 INFO 8108 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-06-20 12:59:25.411 INFO 8108 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2018-06-20 12:59:25.411 INFO 8108 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2018-06-20 12:59:25.500 INFO 8108 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-20 12:59:25.687 INFO 8108 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for #ControllerAdvice: org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#39de3d36: startup date [Wed Jun 20 12:59:24 IST 2018]; root of context hierarchy
2018-06-20 12:59:25.731 INFO 8108 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/messages],methods=[POST]}" onto public java.lang.String com.journaldev.spring.HomeController.saveMessage(java.lang.String,javax.servlet.http.HttpServletRequest)
2018-06-20 12:59:25.732 INFO 8108 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String com.journaldev.spring.HomeController.home(org.springframework.ui.Model,javax.servlet.http.HttpSession)
2018-06-20 12:59:25.734 INFO 8108 --- [ 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-06-20 12:59:25.735 INFO 8108 --- [ 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-06-20 12:59:25.757 INFO 8108 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-20 12:59:25.758 INFO 8108 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2018-06-20 12:59:25.844 INFO 8108 --- [ main] o.s.b.a.w.s.WelcomePageHandlerMapping : Adding welcome page template: index
2018-06-20 12:59:26.005 WARN 8108 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$ServletSessionRepositoryValidator': Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.session.SessionRepositoryUnavailableException: No session repository could be auto-configured, check your configuration (session store type is 'jdbc')
2018-06-20 12:59:26.006 INFO 8108 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2018-06-20 12:59:26.008 INFO 8108 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2018-06-20 12:59:26.023 INFO 8108 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-06-20 12:59:26.032 ERROR 8108 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$ServletSessionRepositoryValidator': Invocation of init method failed; nested exception is org.springframework.boot.autoconfigure.session.SessionRepositoryUnavailableException: No session repository could be auto-configured, check your configuration (session store type is 'jdbc')
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:138) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:424) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1700) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at com.journaldev.spring.SpringSessionExampleApplication.main(SpringSessionExampleApplication.java:10) [classes/:na]
Caused by: org.springframework.boot.autoconfigure.session.SessionRepositoryUnavailableException: No session repository could be auto-configured, check your configuration (session store type is 'jdbc')
at org.springframework.boot.autoconfigure.session.SessionAutoConfiguration$AbstractSessionRepositoryValidator.checkSessionRepository(SessionAutoConfiguration.java:257) ~[spring-boot-autoconfigure-2.0.3.RELEASE.jar:2.0.3.RELEASE]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135) ~[spring-beans-5.0.7.RELEASE.jar:5.0.7.RELEASE]
... 18 common frames omitted
My application.properties:
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/SpringSessionDB
spring.datasource.username=pankaj
spring.datasource.password=pankaj
spring.session.store-type=jdbc
spring.session.jdbc.initialize-schema=always
Dependencies:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-core</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
I am not sure what is missing here?
You are missing the spring-session-jdbc dependency so the JdbcOperationsSessionRepository isn't present on the classpath. Your dependency management provides only spring-session-core dependency, which provides only Spring Session core API - the concrete SessionRepository implementations are placed in dedicated modules i.e. spring-session-data-redis, spring-session-jdbc, spring-session-hazelcast etc.
Once you do that, you can also remove the spring.session.store-type configuration property. As long as you have a single SessionRepository implementation on the classpath, Spring Boot will be able to deduce which one to auto-configure without you having to provide spring.session.store-type.
Having said that, Initializr should be able to include spring-session-jdbc for you however I believe you originally only selected Web, Session and MySQL options when creating project on Initialzr. Together with Session option, you should also select the store you intend to use (like JDBC in this case) so the Initializr can include the required Spring Session module.
On a final note, the arrangement with Spring Session modules changed in Spring Session 2.0, as previously all the code and SessionRepository implementations were placed in spring-session artifact which doesn't exist anymore in Spring Session 2.0. You can learn more about this in in the reference manual and have been mentioned in the 2.0.0.RELEASE announcement.

Spring #ComponentScan isn't picked up, maybe due to #EnableAutoConfiguration in #SpringBootApplication?

i'm new to SpringBoot and am currently reaching to understand the base functionality for a spring application with hibernate.
I have a package com.yyyyyyyyyyy.coaching and if I put all #Entity definitions there the app runs successfully. I was happy to get up and running quick.
Now I moved one entity to com.yyyyyyyyyyy.i18n.bo since it should later be used elsewhere and hibernate throws the following error:
Caused by: org.hibernate.AnnotationException: #OneToOne or #ManyToOne on com.yyyyyyyyyyy.coaching.bo.Topic.descriptionStrings references an unknown entity: com.yyyyyyyyyyy.i18n.bo.Localized
(see below for the full --debug application startup)
I understand that #ComponentScan should be used to specify which packages are scanned for annotations.
I have double checked that javax.persistence.Entity is used everywhere and not the one from the hibernate package.
Here is my program entry point:
#SpringBootApplication(scanBasePackages={"com.yyyyyyyyyyy"})
//#Configuration
//#ComponentScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})
#Import(AppConfig.class)
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
It doesn't find the Entity with scanBasePackages, with ComponentScan on the main class and also when using #Import and another config class "AppConfig". I also tried to use the ApplicationBuilder instead of SpringApplication like this new SpringApplicationBuilder().sources(AppConfig.class).main(DemoApplication.class).run(args); but to no avail.
What I can see from the debug output is the line:
2015-11-18 08:08:48.407 DEBUG 13780 --- [ main] o.s.b.a.AutoConfigurationPackages : #EnableAutoConfiguration was declared on a class in the package 'com.yyyyyyyyyyy.coaching'. Automatic #Repository and #Entity scanning is enabled.
I suppose this doesn't hurt as it comes from the #SpringBootApplication annotation
The AppConfig class doesn't seem to be included either, as I added debug output which isn't printed.
#Configuration
//#Profile("production")
#ComponentScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})
public class AppConfig {
public AppConfig() {
System.out.println("------------------------------Init AppConfig-------------------------");
}
#PostConstruct
public void doSomething() {
System.out.println("------------------------------Done AppConfig-------------------------");
}
}
Any help/ideas on this?
Thanks.
Edit, prj structure:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.0.RELEASE)
2015-11-18 08:08:47.048 INFO 13780 --- [ main] c.yyyyyyyyyyy.coaching.DemoApplication : Starting DemoApplication on Suse with PID 13780 (started by Klaus in C:\Users\Klaus\Downloads\demo (1)\demo)
2015-11-18 08:08:47.051 INFO 13780 --- [ main] c.yyyyyyyyyyy.coaching.DemoApplication : No profiles are active
2015-11-18 08:08:47.051 DEBUG 13780 --- [ main] o.s.boot.SpringApplication : Loading source class com.yyyyyyyyyyy.coaching.DemoApplication
2015-11-18 08:08:47.098 DEBUG 13780 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'classpath:/application.properties'
2015-11-18 08:08:47.098 DEBUG 13780 --- [ main] o.s.b.c.c.ConfigFileApplicationListener : Skipped (empty) config file 'classpath:/application.properties' for profile default
2015-11-18 08:08:47.103 INFO 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1fc32e4f: startup date [Wed Nov 18 08:08:47 CET 2015]; root of context hierarchy
2015-11-18 08:08:47.106 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Bean factory for org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#1fc32e4f: org.springframework.beans.factory.support.DefaultListableBeanFactory#7a1a3478: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,demoApplication]; root of factory hierarchy
2015-11-18 08:08:48.286 INFO 13780 --- [ 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]]
2015-11-18 08:08:48.407 DEBUG 13780 --- [ main] o.s.b.a.AutoConfigurationPackages : #EnableAutoConfiguration was declared on a class in the package 'com.yyyyyyyyyyy.coaching'. Automatic #Repository and #Entity scanning is enabled.
2015-11-18 08:08:48.995 INFO 13780 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$4e01ef7c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2015-11-18 08:08:49.038 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource#2e17a321]
2015-11-18 08:08:49.038 DEBUG 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Using ApplicationEventMulticaster [org.springframework.context.event.SimpleApplicationEventMulticaster#521bb1a4]
2015-11-18 08:08:49.368 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\Klaus\.m2\repository\org\springframework\boot\spring-boot\1.3.0.RELEASE\spring-boot-1.3.0.RELEASE.jar
2015-11-18 08:08:49.369 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : Code archive: C:\Users\Klaus\.m2\repository\org\springframework\boot\spring-boot\1.3.0.RELEASE\spring-boot-1.3.0.RELEASE.jar
2015-11-18 08:08:49.369 DEBUG 13780 --- [ main] .t.TomcatEmbeddedServletContainerFactory : None of the document roots [src/main/webapp, public, static] point to a directory and will be ignored.
2015-11-18 08:08:49.419 INFO 13780 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-11-18 08:08:49.433 INFO 13780 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2015-11-18 08:08:49.434 INFO 13780 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.28
2015-11-18 08:08:49.566 INFO 13780 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2015-11-18 08:08:49.566 INFO 13780 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 2467 ms
[..]
2015-11-18 08:08:49.960 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-11-18 08:08:49.960 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-11-18 08:08:49.961 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2015-11-18 08:08:49.961 INFO 13780 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2015-11-18 08:08:49.982 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.web.OrderedRequestContextFilter : Initializing filter 'requestContextFilter'
2015-11-18 08:08:49.984 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.web.OrderedRequestContextFilter : Filter 'requestContextFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] .s.b.c.w.OrderedHttpPutFormContentFilter : Initializing filter 'httpPutFormContentFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] .s.b.c.w.OrderedHttpPutFormContentFilter : Filter 'httpPutFormContentFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedHiddenHttpMethodFilter : Initializing filter 'hiddenHttpMethodFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedHiddenHttpMethodFilter : Filter 'hiddenHttpMethodFilter' configured successfully
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedCharacterEncodingFilter : Initializing filter 'characterEncodingFilter'
2015-11-18 08:08:49.985 DEBUG 13780 --- [ost-startStop-1] o.s.b.c.w.OrderedCharacterEncodingFilter : Filter 'characterEncodingFilter' configured successfully
2015-11-18 08:08:50.825 INFO 13780 --- [ main] liquibase : Successfully acquired change log lock
2015-11-18 08:08:50.917 INFO 13780 --- [ main] liquibase : Reading from broadleaf.DATABASECHANGELOG
2015-11-18 08:08:50.926 INFO 13780 --- [ main] liquibase : Successfully released change log lock
2015-11-18 08:08:51.116 INFO 13780 --- [ main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2015-11-18 08:08:51.128 INFO 13780 --- [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [
name: default
...]
2015-11-18 08:08:51.210 INFO 13780 --- [ main] org.hibernate.Version : HHH000412: Hibernate Core {4.3.11.Final}
2015-11-18 08:08:51.211 INFO 13780 --- [ main] org.hibernate.cfg.Environment : HHH000206: hibernate.properties not found
2015-11-18 08:08:51.214 INFO 13780 --- [ main] org.hibernate.cfg.Environment : HHH000021: Bytecode provider name : javassist
2015-11-18 08:08:51.394 INFO 13780 --- [ main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
2015-11-18 08:08:51.441 INFO 13780 --- [ main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
2015-11-18 08:08:51.557 WARN 13780 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
2015-11-18 08:08:51.567 INFO 13780 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2015-11-18 08:08:51.574 INFO 13780 --- [ main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [ ...
2015-11-18 08:08:51.578 ERROR 13780 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1051) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:828) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:347) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
at com.yyyyyyyyyyy.coaching.DemoApplication.main(DemoApplication.java:23) [classes/:na]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849) ~[hibernate-entitymanager-4.3.11.Final.jar:4.3.11.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:318) ~[spring-orm-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.2.3.RELEASE.jar:4.2.3.RELEASE]
... 16 common frames omitted
Caused by: org.hibernate.AnnotationException: #OneToOne or #ManyToOne on com.yyyyyyyyyyy.coaching.bo.Topic.descriptionStrings references an unknown entity: com.yyyyyyyyyyy.i18n.bo.Localized
Move DemoApplication class to com.yyyyyyyyyyy package and everything should work. Everything which is in com.yyyyyyyyyyy should be picked automatically.
Check this out how spring boot recommend structuring
UPDATE:
also as you saw in the ref documentation add
add #EntityScan(basePackages={"com.yyyyyyyyyyy.coaching", "com.yyyyyyyyyyy.i18n"})to DemoApplication will work.

Resources