The FixtureScriptsSpecificationProvider configures the FixtureScripts domain service, providing the location to search for fixture scripts and other settings.

The service is used only by the default implementation of FixtureScripts, namely FixtureScriptsDefault.

Of the two designs, we encourage you to implement this "provider" SPI rather than subclass FixtureScripts. The primary benefit (apart from decoupling responsibilities) is that it ensures that there is always an instance of FixtureScripts available for use.


The SPI defined by the service is:

public interface FixtureScriptsSpecificationProvider {
    FixtureScriptsSpecification getSpecification();

where FixtureScriptsSpecification exposes these values:

public class FixtureScriptsSpecification {
    public String getPackagePrefix() { /* ... */ }
    public FixtureScripts.NonPersistedObjectsStrategy getNonPersistedObjectsStrategy() { /* ... */ }
    public FixtureScripts.MultipleExecutionStrategy getMultipleExecutionStrategy() { /* ... */ }
    public Class<? extends FixtureScript> getRunScriptDefaultScriptClass() { /* ... */ }
    public DropDownPolicy getRunScriptDropDownPolicy() { /* ... */ }
    public Class<? extends FixtureScript> getRecreateScriptClass() { /* ... */ }

The class is immutable but it has a builder (obtained using FixturescriptsSpecification.builder(…​)) for a fluent API.


The SimpleApp starter app has a simple implementation of this service:

import org.springframework.stereotype.Service;

public class DomainAppFixturesProvider implements FixtureScriptsSpecificationProvider {
    public FixtureScriptsSpecification getSpecification() {
        return FixtureScriptsSpecification