fix: fixed the error that the file could not be found after packing
This commit is contained in:
parent
847bbbdd22
commit
8779c629e7
@ -32,7 +32,7 @@ public class DefaultTbMailConfigTemplateService implements TbMailConfigTemplateS
|
||||
|
||||
@PostConstruct
|
||||
private void postConstruct() throws IOException {
|
||||
mailConfigTemplates = JacksonUtil.toJsonNode(new ClassPathResource("/templates/mail_config_templates.json").getFile());
|
||||
mailConfigTemplates = JacksonUtil.toJsonNode(new ClassPathResource("/templates/mail_config_templates.json").getInputStream());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -35,6 +35,7 @@ import org.thingsboard.server.common.data.kv.KvEntry;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
@ -182,6 +183,15 @@ public class JacksonUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static JsonNode toJsonNode(InputStream value) {
|
||||
try {
|
||||
return value != null ? OBJECT_MAPPER.readTree(value) : null;
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException("The given InputStream value: "
|
||||
+ value + " cannot be transformed to a JsonNode", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static ObjectNode newObjectNode() {
|
||||
return newObjectNode(OBJECT_MAPPER);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user