我想要一个工具,从负载方法连接起来,使可检索数据并把ehcache.The问题米朝里是@Autowiring
没有内部MyBootstrapCacheLoaderFactory
或任何其他类中工作(获得从加载方法调用)。我会很高兴,如果任何人都可以提供一些解决方案。创建每一个例子是不可能的,也没有它的帮助一些服务..提前感谢。ehcache的/ JVM启动
@Component
public class TestingBootstrapCacheLoaderFactory extends BootstrapCacheLoaderFactory implements BootstrapCacheLoader{
@Autowired
Services service;
@Override
public BootstrapCacheLoader createBootstrapCacheLoader(Properties properties) {
// TODO Auto-generated method stub
return new MyBootstrapCacheLoaderFactory();
}
@Override
public Object clone() throws CloneNotSupportedException {
// TODO Auto-generated method stub
return super.clone();
}
public boolean isAsynchronous() {
// TODO Auto-generated method stub
return false;
}
public void load(Ehcache myCache) throws CacheException {
// TODO Auto-generated method stub
System.out.println("load your cache with whatever you want....");
service.connect(); //null pointer as autowired doesnt work
//nor it is working if i create a class object here and try to user
//other class for autowiring
}
一个'@ Autowired'字段不能是'null'如果这将是应用程序将无法启动。您可能正在创建'TestingBootstrapCacheLoaderFactory'的新实例,而不是让Spring创建实例。 –
嗨@ M.Deinum感谢reply.As你知道TestingBootstrapCacheLoaderFactory被称为在JVM startup.This的时间,我已经写了确切的代码,并抛出空指针,如果我试图抓住exception.I尝试使用自动装配,并与创建enviornment实例面对.environement.getproperty问题米抛出空pointer.Yaa想确认我的应用程序是starting.I试图从这个链接http://forums.terracotta.org/forums/posts/list/4335.page解决方案,但是,这是NT工作对于我 –
如果我将尝试在此类中创建@Autowired Environment env,那么env将为空。 –