File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Spring_part_3/src/main/java/spring/oldboy/lesson_16 Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package spring .oldboy .lesson_16 ;
2+
3+ import org .springframework .context .support .ClassPathXmlApplicationContext ;
4+ import spring .oldboy .repository .CrudRepository ;
5+
6+ public class FirmRepositoryDemo {
7+ public static void main (String [] args ) {
8+
9+ try (var context = new ClassPathXmlApplicationContext ("application.xml" )) {
10+
11+ /*
12+ В данном примере FirmRepository.java практически ничем
13+ не аннотирован, однако Spring находит его в IoC контейнере,
14+ поскольку мы соответствующим образом настроили
15+ */
16+ CrudRepository firmRepository =
17+ context .getBean ("firmRepository" , CrudRepository .class );
18+ System .out .println (firmRepository .findById (1 ));
19+ /*
20+ 2.postProcessBeanFactory - VerifyPropertyBeanFactoryPostProcessor
21+ 1.postProcessBeanFactory - LogBeanFactoryPostProcessor
22+ Init connection pool
23+ init company repository
24+ init company repository
25+ init company repository
26+ findById method...
27+ Optional[Company[id=1]]
28+ Clean connection pool
29+ */
30+ }
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments