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); } }