I am developing a web application with maven, spring 2.5 and some other technologies. The application it is composed of 3 layer dao service and web, the dao and service are packed as jar and used as libraries for my web application which is finally packed as a ear this is the final structure.
myappp.ear
--mywebapp.war
--lib
--dao.jar
--service.jar
Until now i have deployed the reports (.jasper) in the web layer defined in views.xml file. Now i am trying to move my reports to the service. The problems i have faced is that a can not load my reports. this a sample code
public class myreportingservice{
private InputStream report;
@autowired
public void setReport(InputStream report){
this.report = report;
}
//THE CODE THAT EJECUTES THE REPORT.
}
This is the xml that loas the config.
<beans xmlns .........
<bean id="formatoTiempoEnProcesos" class="java.io.FileInputStream">
<constructor-arg value="c:/evaluacionDeProveedores.jasper"> </constructor-arg>
</bean>
</beans>
as you can see in the *constructor arg * it is wrote the whole path and it woks fine, but if i want to use a relative path the bean can not be loaded, i have tried with this "classpath:/reportes/evaluacionDeProveedores.jasper" and "/reportes/evaluacionDeProveedores.jasper" and many 开发者_如何学Pythonways but unt now i just get errors.
Hope some one can help me.
classpath:/relative/path
should be resolved to a Resource
, so change your bean field from InputStream
to org.springframework.core.io.Resource
. You can then call .getInputStream()
on the resource
精彩评论