@Autowired 使用问题
半支烟z 2010-02-27 10:03:52 @Component("testhost")
public class Testhost {
public void toprint()
{
System.out.println("Testhost of toprint");
}
}
----------------------------
@Component("testss")
public class Testss
{
@Autowired
public Testhost th;
public void toth()
{
th.toprint();
}
}
--------------------------------
public class Main01 {
public static void main(String[] args) {
Testss tss=new Testss();
tss.toth();
}
}
、、、、、、、、、、、、、错误
Exception in thread "main" java.lang.NullPointerException
at aop.test.Testss.toth(Testss.java:14)
at aop.test.Main01.main(Main01.java:10)
应该怎么用呢?