2015-03-02 4 views
2

Я пытаюсь использовать переменную classpath, но всегда получаю FileNotFoundException.переменная переменной переменной Spring не работает

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd 
     http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
     http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd"> 


    <tx:annotation-driven /> 
    <context:component-scan base-package="ar.com.conexia.salud.*" /> 

    <bean id="pdfGenerator" class="ar.com.conexia.generator.PdfGenerator"> 
<!--  <constructor-arg 
      value="#{systemProperties['catalina.home']}/webapps/COMEI_Beneficiario/WEB-INF/classes/reports/" /> --> 
     <constructor-arg value="classpath:/reports/" /> 
     <constructor-arg value="C://reports//" /> 
    </bean> 

</beans> 

Как вы можете видеть, я попытался использовать catalina.home переменные в качестве альтернативы, чтобы проверить, что у меня нет какой-либо другой проблемы с файлом, и это нормально.

Спасибо.

EDIT: Я объединяю эти базовые пути с именем файла, чтобы открывать файлы.

ответ

0

попробовать это в файле XML поместить

<context:component-scan base-package="com.your.package.name" /> 

и создать класс

@Configuration 
public class Config { 
    @Bean 
    public PdfGenerator sessionFactoryBean(){ 
     PdfGenerator pdfGen=new PdfGenerator("classpath:/reports/","C://reports//"); 
     return pdfGen; 
    } 
} 
Смежные вопросы