Solve the problem that the content of the resources folder is not automatically copied to the output path classes when the idea is compiled

There is a concept of Content Roots in idea. The corresponding Content Roots need to be configured for each folder. Content Roots include resources, sources, tests, etc.

write picture description here
as the picture shows:

  • The java folder is marked as Sources, then all the subfolders below are Sources, and .class files are generated after compilation.
  • The Resources folder is marked as Resources, then the configuration files in this folder will be automatically copied to the compilation folder when compiling.
When the folders under the sources are not automatically copied to the output path classes during compilation, you can refer to the following solutions:
The resource file directory is the resource at the same level as src, which contains two resource files, applicationContext.xml and log4j.properties. The project compilation directory is WEB-INF/classess,

 

 

 

And specify resource as the resource directory:

 

 

 

 

There is no problem with the compilation directory specified:

 

 

 

Click to compile and restart tomcat, the resource files are never copied to the classes directory. The strange thing is that the company's machine does not have this problem, but the home machine has this problem.

 

Later, rebuild the project and the problem is gone:

 

Build --> reBuild Project

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326418344&siteId=291194637