在项目 startup/Jvm 启动期间加载 ehcache
Loading ehcache during project startup/Jvm Start up
我正在尝试从加载方法连接一个工具,以便可以检索数据并将其放入 ehcache.The 我面临的问题是 @Autowiring
在 MyBootstrapCacheLoaderFactory
内部或任何其他内部都不起作用class(从加载方法调用)。如果有人能提供一些 solution.Creating 每个实例都不可能,也无法帮助提供某些服务,我将很高兴。提前致谢。
@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
}
在我的方法上方提供 @Postconstruct 注释对我有效
我正在尝试从加载方法连接一个工具,以便可以检索数据并将其放入 ehcache.The 我面临的问题是 @Autowiring
在 MyBootstrapCacheLoaderFactory
内部或任何其他内部都不起作用class(从加载方法调用)。如果有人能提供一些 solution.Creating 每个实例都不可能,也无法帮助提供某些服务,我将很高兴。提前致谢。
@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
}
在我的方法上方提供 @Postconstruct 注释对我有效