Spring Boot should we always use interfaces even with one implementation quick question. I'm using Spring Boot and I created e.g. this class
public interface ProductService {

    Page&lt;Product&gt; getPage(Pageable pageable);

}

@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductRepository productRepository;

    @Override
    public Page&lt;Product&gt; getPage(String name, Pageable pageable) {
        return productRepository.findAll(pageable);
    }
}

And this interface has only one implementation. And what is better to use interface with one implementation and inject interface or just create a class without interface and inject class?
The answer to this question may vary depending on the opinions regarding the various so-called &quot;good practices&quot;.
If we take into account the dependency inversion principle (In SOLID principles), then we should always aim for our classes to depend on abstractions and not on implementations.
However we could also take into account the &quot;KISS&quot; principle (Keep it stupidly simple) and in this way I could tell you that if your application is not very large or complex, then do not use an interface.
Answering your question: &quot;what is better to use interface with one implementation and inject interface or just create a class without interface and inject class?&quot;
I recommend using an interface even if it has only one implementation, so in the future if the implementation changes, the class that depends on said interface will not be affected by said change, unless the interface signature changes as well.