sYsTeM
sYsTeM

Reputation: 37

How to add YML files to my project using VSCODE?

In my Java project when inserting a YAML file, I realize there is an exclamation point. When compiling using Maven commands, I can not find the YAML file inside the .jar file. I need this YAML to be inside the .jar file.

I think the exclamation point is not normal, as you can see below:

Image

If this is not normal, how can I solve this problem? How can I add YAML files to my project?

Upvotes: 0

Views: 4076

Answers (1)

mkasberg
mkasberg

Reputation: 17322

Normally, you'd put files like properties and yaml files in a directory called src/main/resources. Build tools like Maven and Gradle will scan this directory for files and include them in the jar (typically without additional config). If it is just in the src directory, and you don't have special configuration to tell Maven to add files from that directory to your jar, it won't.

When files are in the src/main/resources directory, you'll be able to access them in your application on the classpath, with something like App.class.getResourceAsStream().

Upvotes: 2

Related Questions