|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 |
import
java.util.Iterator;import
java.util.LinkedList;import
javax.annotation.PostConstruct;import
javax.annotation.Resource;import
org.junit.Test;import
org.junit.runner.RunWith;import
org.springframework.beans.factory.annotation.Autowired;import
org.springframework.jdbc.core.JdbcTemplate;import
org.springframework.test.context.ContextConfiguration;import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner;@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"../../../../../spring.xml"})public
class AutoDown{ @Autowired private
JdbcTemplate jdbcTemplate; private
static AutoDown autoDown; @PostConstruct public
void init(){ System.out.println("1111"); autoDown = this; autoDown.jdbcTemplate = this.jdbcTemplate; System.out.println("init"); } @Test public
void testStatic(){ System.out.println("11111111"); System.out.println(autoDown.jdbcTemplate); int
i = autoDown.jdbcTemplate.queryForObject("select count(1) from siminfo", Integer.class); System.out.println(i); } } |
原文:http://www.cnblogs.com/rench/p/3555443.html