Skip to content

matek2305/spring-data-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov.io Dependency Status Maven Central Codacy Badge

spring-data-loader

Simple util to help loading presentation/development data for your Spring based application.

Maven

<dependency>
    <groupId>com.github.matek2305</groupId>
    <artifactId>spring-data-loader</artifactId>
    <version>0.9.0</version>
</dependency>

Usage

After adding dependency to your pom.xml, build.gradle etc. you must mark your configuration (or main class when using Spring Boot) with @EnableDataLoader annotation like in example below (@Profile("dev") is not needed):

@Profile("dev")
@Configuration
@EnableDataLoader
public class DevDataLoaderConfiguration {
}

After that all your beans implementing DataLoader interface will be executed during application startup so you can place your data there. If there are more than one bean and one depends on another there is @LoadDataAfter annotation to mark dependencies.

@Component
@LoadDataAfter(RoleDataLoader.class)
public class UserDataLoader implements DataLoader {

    @Override
    public void load() {
      // this will be exected after RoleDataLoader#load
    }
}

@Component
public class RoleDataLoader implements DataLoader {

    @Override
    public void load() {
      // load your roles data here
    }
}

Example

You can check usage example of spring-data-loader here.

Contribute

This is my first public utility library and I would be grateful for your improvement ideas, so feel free to open an issue or contribute.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages