Create Schema automatically
https://stackify.com/spring-boot-level-up/

 if you want to add initial data to the database, you can create files with standard names such as schema.sql, data.sql or import.sql to be picked up automatically by Spring Boot auto-configuration, or you can define your DataSourcebean to load a custom named SQL script manually:
@Configuration
public class PersistenceConfig {

    @Bean
    public DataSource dataSource() {
        EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
        EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2)
          .addScript("mySchema.sql")
          .addScript("myData.sql")
          .build();
        return db;
    }
}
This has the effect of overriding the auto-configured DataSource bean, but not the rest of the default beans that make up the configuration of the persistence layer.


The entry point for a Spring Boot application is the main class annotated with @SpringBootApplication:
The shortcut @SpringBootApplication annotation is equivalent to using @Configuration@EnableAutoConfiguration, and @ComponentScan and will pick up all config classes in or bellow the package where the class is defined.

Comments

Popular posts from this blog

Difference between Dependency Management and Dependencies in Maven

Maa swett age of First Luv..