I use spring-mvc mybatis 3.2.8. I want to read some image from database and store in on ApplicationContext. I have a dao class to read image
dao class
public Interface DaoImage {
public List<byte[]> selectImage();
}
InitializationService.java
public interface InitializationiService {
public List<byte[]> loadImage();
}
InitializationServiceImpl.java
public class InitializationImpl implements InitializationService{
@Autowoired
private DaoImage img;
@Overrides
public List<byte[]> loadImage(){
return img.selectImage();
}
}
InitializeApplication.java
public class InitializationApplication extends ContextLoaderListener{
@Autowired
private InitializationService service;
@Override
public void contextInitialized(ServletContextEvent event) {
List<byte[]> list = service.loadImage();
event.getServletContext().setAttribute("contextImage", list);
}
}
When the application start the List list = service.loadImage(); is null.
Can anyone help ?
I have found the solutioin now :