#better ways to load xml as a string?
1 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @remote spire! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
You shouldn't assume anything in src/main/resources is a file
If you package your application, it will likely not be available any more
It is a resource so you should access it as such
using getClass().getClassLoader().getResource("accountStatementRequestBodyTemplate.xml")
thanks. i found this: https://www.baeldung.com/spring-load-resource-as-string
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
but now idk what to use. so many choices
depends on the situation
can u elaborate?
In most cases, I'd use Class#getResource or similar
what am i doing wrong?
getClass().getClassLoader().getResource("accountStatementRequestBodyTemplate.xml")
or getClass().getClassLoader().getResourceAsStream("accountStatementRequestBodyTemplate.xml")
i dont understand
You can get an InputStream for something in src/main/resources with that method