SpringMVCサイト内でVelocityを使用してメールをテンプレート化しようとしています。Velocityが私が使用したいテンプレートを見つけることができれば、すべてがうまくいくと思います。にテンプレートがあり/WEB-INF/emails/faultNotification.vm
ます。私のコードでは、これがあります:
MimeMessageHelper helper = new MimeMessageHelper (message, true);
helper.setTo (toAddresses);
helper.setSubject (subject);
Map<String, Object> model = new HashMap<> ();
model.put ("username", "nikitin");
model.put ("emailAddress", "nik.estep@gmail.com");
helper.setText (VelocityEngineUtils.mergeTemplateIntoString (
m_emailEngine,
"faultNotification.vm",
model), true);
helper.addAttachment (attachmentName,
new ByteArrayResource (attachment.toByteArray ()),
"application/zip");
m_sender.send (message);
私のXMLには、次のものがあります。
<bean id="velocityEngine" class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="resourceLoaderPath" value="file:/WEB-INF/emails" />
</bean>
<bean id="emailSender" class="com.tarigma.gem.communication.EmailSender">
<constructor-arg ref="systemSettings" />
<constructor-arg ref="velocityEngine" />
</bean>
私は見つけた投稿を読んでいて、私が言えることから、これはうまくいくはずですが、Velocityはそれを使用しようとするとテンプレートを見つけることができません(ERROR VelocityEngine - ResourceManager: Unable to find resource 'faultNotification.vm' in any resource loader
)。テンプレートを入れたくない/WEB-INF/classes
のは、それがそのフォルダーに入るものではなく、これを機能させる方法が必要だからです。どんな助けでもありがたいです、私はこれを解決しようとして昨日すべてを失いました。