I have a question about eclipse.
properties file in external folder
I'd like to load it.
from the VM argument in eclipse
Java Build Path > Library > Class Path
Is there a way to set up an external folder?
Thank you for your cooperation.
Supplemental
because I read messages.properties values directly into html using Thymeleaf.
I want to add an external directory to the class path.
When running from Eclipse (STS), "Java Build Path > Library > Class Path External Folder" allows you to read external messages.properties
, but is this the question intended to specify when running with the java-jar<spring-boot app >
command?
The location of the message source (resource bundle) is specified by spring.massages.basename
, where you can also specify a file (base name) on the file system ( file:
Property settings can also be specified with command-line arguments (4.2.2.Accessing Command Line Properties).
Therefore, if ./external-resources/messages.properties
is the file you want to read,
java-jar<spring-boot app>.jar --spring.messages.basename=file:external-resources/messages
available on the .
Execution sample code , war version
using ThymeleafWhen deploying to Tomcat, Tomcat needs to be directed.Learn more about how to configure:
Tomcat9 deploys the aforementioned war and reads the message resources under the /tmp/external-resources
directory.
messages.properties
file under the /tmp/external-resources/
directoryconf/Catalina/localhost/demo-0.0.1-SNAPSHOT.xml
file under Tomcat's main body.Includes:<Context>
<Resources>
<PostResources
className="org.apache.catalina.webresources.DirResourceSet"
base="/tmp/external-resources"
webAppMount="/WEB-INF/classes"/>
</Resources>
</Context>
With this configuration, the /tmp/external-resources
directory is inserted into the war file /WEB-INF/classes
so that applications can find message resources in the class path.
© 2024 OneMinuteCode. All rights reserved.