Seeders populate your database with initial or test data. Annotate your class with @Seeder and implement SeederInterface — the framework runs them automatically at startup. Use the priority parameter to control execution order when multiple seeders depend on each other.
@Seeder(priority = 10)
public class ArticleSeeder implements SeederInterface {
@Inject
private ArticleRepository articleRepository;
@Override
public void seed() {
if (!articleRepository.findAll().isEmpty()) {
return;
}
articleRepository.create(
"Getting started with Obsidian",
"Obsidian is a lightweight Java web framework..."
);
articleRepository.create(
"Building REST APIs",
"Learn how to build REST APIs with Obsidian..."
);
}
}
priority values run first — use this when seeders depend on each other@Inject works in seeders the same way as in controllers