user829237
user829237

Reputation: 1759

Spring - Paths in applicationContext.xml

I am defining a freemarker bean in my applicationContext.xml and this bean needs a path to my template-directory. It used to be:

src/main/webapp/template/

But i now want to store my templates under:

src/main/resources/template/

It used to look like:

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="/template/email/"/>
</bean>

Can anyone please help me to correctly define the new path?

Upvotes: 2

Views: 1561

Answers (1)

kan
kan

Reputation: 28951

Answering as a proper answer, so you can close the question.

You should use "classpath:" prefix to reference resources located in the classpath.

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
    <property name="templateLoaderPath" value="classpath:/template/email/"/>
</bean>

Upvotes: 1

Related Questions