IoC - , , Java, , , / , - .
Spring IoC/DI . , , , /, , ( ).
DAO, :
interface IPersonDao {
List<Person> getPersonsByTeam(String teamName);
}
src, Spring "". , :
class MyService {
@Autowired
IPersonDao svc;
}
:
class TestPersonDao {
@Autowired
IPersonDao svc;
@Test
void testGetPersons(){
List<Person> persons = svc.getPersonsByTeam("billing");
Assert.assertDataSet(persons, "billing.xml");
}
}
, Dao , Dao. , , :
class JpaPersonDao implements IPersonDao {
@PersistenceContext
EntityManager em;
List<Person> getPersonsByTeam(String tm) {
em.createQuery("...");
}
}
, beans. , DI, . , Spring , , , mvc, , hibernate, jpa / db, , , Spring IoC.