I am working on a spring boot application that uses H2, JPA, and maven. I want spring boot to create my tables automatically. But If I dont want to put my entity classes where I put my core classes. If I do not put my entity classes in the same or subpackage of my core package where I have my @SpringBootApplication notation then the spring does not create my tables. I wonder is there a way to work this around? I want to put my entity classes into different package than my @SpringBootApplication class and still make spring to create my tables in H2. Please see below. As you see my entity class is in com.dao and my runner class is in com.core.
package com.dao;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "method")
public class Method {
@Id
private long id;
private String name;
// Setters getters
}
package com.core;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Runner {
public static void main(String[] args) {
SpringApplication.run(Runner.class, args);
System.out.println("Boot");
}
}

