Skip to content
This repository was archived by the owner on Jan 18, 2019. It is now read-only.

Commit 4b4b722

Browse files
author
Sergey Doronin
committed
Попытка загрузки spring контекста из запускающего файла
1 parent 4bc5234 commit 4b4b722

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package org.dyndns.phpusr.contactmanager.execute;
2+
3+
import org.dyndns.phpusr.contactmanager.entity.Student;
4+
import org.dyndns.phpusr.contactmanager.service.StudentService;
5+
import org.springframework.context.ApplicationContext;
6+
import org.springframework.context.support.ClassPathXmlApplicationContext;
7+
8+
import java.io.File;
9+
10+
/**
11+
* @author Sergey Doronin
12+
* Date: 16.04.12
13+
* Time: 17:35
14+
*/
15+
public class Run {
16+
17+
public static void main(String[] args) {
18+
File file = new File("");
19+
20+
ApplicationContext appContext =
21+
new ClassPathXmlApplicationContext("src/main/java/webapp/WEB-INF/resources/spring/root-context.xml");
22+
23+
StudentService studentDao = (StudentService)appContext.getBean("studentDaoDefault");
24+
studentDao.addStudent(new Student("maloi", "sur", "Limp Bizkit"));
25+
26+
System.out.println("Well Done!");
27+
}
28+
}

src/test/java/org/dyndns/phpusr/contactmanager/service/StudentServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class StudentServiceTest {
2222

2323
@Autowired
24-
@Qualifier("studentServiceDefault")
24+
@Qualifier("hello")
2525
StudentService service;
2626

2727
@Before

src/test/java/org/dyndns/phpusr/contactmanager/service/StudentServiceTestImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
@Service("hello")
1515
public class StudentServiceTestImpl implements StudentService {
16+
public static final String PREFIX = ">>";
1617

1718
public void addStudent(Student student) {
18-
//To change body of implemented methods use File | Settings | File Templates.
19+
System.out.println(PREFIX + "Adding student: " + student);
1920
}
2021

2122
public List<Student> getStudents() {
22-
return null; //To change body of implemented methods use File | Settings | File Templates.
23+
System.out.println(PREFIX + "Getting students");
24+
return null;
2325
}
2426

2527
public void removeStudent(Student student) {

0 commit comments

Comments
 (0)