복붙노트

[SPRING] 속도의 로더 경로를 올바르게 설정하는 방법

SPRING

속도의 로더 경로를 올바르게 설정하는 방법

내 velocityengine은 설계된 경로에서 템플릿을 찾습니다. 저는 이것을 했어요 :

<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
 <property name="velocityProperties">
   <value>
     resource.loader=class
     class.resource.loader.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
     class.resource.loader.resourceLoaderPath=/mytemplates
   </value>
 </property>

여전히 클래스 폴더에있는 템플릿을 찾고 있습니다. 어떤 생각?

해결법

  1. ==============================

    1.스프링 문서에 설명 된대로 다음을 시도해 볼 수 있습니다.

    스프링 문서에 설명 된대로 다음을 시도해 볼 수 있습니다.

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
      <property name="velocityProperties">
        <props>
          <prop key="resource.loader">file</prop>
          <prop key="file.resource.loader.class">
            org.apache.velocity.runtime.resource.loader.FileResourceLoader
          </prop>
          <prop key="file.resource.loader.path">${webapp.root}/WEB-INF/velocity</prop>
          <prop key="file.resource.loader.cache">false</prop>
        </props>
      </property>
    </bean>
    

    또는 velocity.properties에서 이러한 속성을 선언하고

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
      <property name="configLocation" value="/WEB-INF/velocity.properties"/>
    </bean>
    
  2. ==============================

    2.이 시도:

    이 시도:

    <bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
        <property name="resourceLoaderPath" value="/email_templates/"/>
    </bean>
    
    <bean name="mailTest" class="com.crisil.web.MailTestController">
        <property name="velocityEngine" ref="velocityEngine"/>
    </bean>
    
  3. ==============================

    3.Resource Loader를 다음과 같이 시도하십시오.

    Resource Loader를 다음과 같이 시도하십시오.

    org.apache.velocity.runtime.resource.loader.FileResourceLoader
    

    희망이 도움이됩니다.

  4. from https://stackoverflow.com/questions/5342704/how-to-set-properly-the-loader-path-of-velocity by cc-by-sa and MIT license