Merge pull request #183 from derkoe

* gh-183:
  Test that JPA repositories work when called in an init method

Closes gh-183
This commit is contained in:
Andy Wilkinson
2023-09-21 12:49:56 +01:00

View File

@@ -0,0 +1,20 @@
package com.example.data.jpa;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Service;
@Service
public class AppInitializer implements InitializingBean {
private AuthorRepository authorRepository;
public AppInitializer(AuthorRepository authorRepository) {
this.authorRepository = authorRepository;
}
@Override
public void afterPropertiesSet() throws Exception {
authorRepository.findByNameContainingIgnoreCase("name");
}
}