0

在我们的 quarkus 项目中,我们使用 quarkus 邮件程序和 qute 模板来发送电子邮件。我们的电子邮件正文中有一些图像,因此我们使用内联附件来包含图像。这在本地设置中工作正常,使用./mvnw compile quarkus:dev

如 quarkus 指南中所述,我们在资源配置文件中包含了 html 和图像扩展名 (png)。

但是当我们为我们的项目使用原生构建时,问题就出现了。本机图像中的图像位置似乎不同,因为在发送邮件期间,我们收到异常,因为找不到文件。

包含图像的代码是

mailObject.to(recipient)
    .subject("sample subject")
    .addInlineAttachment("logo.png", new File(getClass().getResource("/images/logo.png").getFile()), "image/png", "<logo@example.git.com>")
    .send().await().indefinitely();

本机图像的输出getClass().getResource("/images/logo.png").getFile()是资源:images/logo.png

上面的输出应该意味着文件存在于指定的位置,因为找不到文件时输出通常为空。

本地设置中的路径位置是src/main/resources/images/logo.png

但是本机图像会出现此异常

Exception : io.vertx.core.file.FileSystemException: Unable to open file at path '/work/images/logo.png'
...
Caused by: java.nio.file.NoSuchFileException: /work/images/logo.png

本机构建中的图像位置似乎不同。这个问题有什么解决方案吗?

4

0 回答 0