[英]Files under src/main/resources goes under target/WEB-INF/classes
The project is a Spring MVC with Maven. 该项目是带有Maven的Spring MVC。
Here is the sample folder structure : 这是示例文件夹结构:
And here is the build part of effective pom 这是有效pom的构建部分
<sourceDirectory>${basedir}\src\main\java</sourceDirectory>
<scriptSourceDirectory>${basedir}\src\main\scripts</scriptSourceDirectory>
<outputDirectory>${basedir}\target\classes</outputDirectory>
<resources>
<resource>
<directory>${basedir}\src\main\resources</directory>
</resource>
</resources>
<directory>${basedir}\target</directory>
<finalName>m2mproject</finalName>
And the target directory comes out like this 目标目录如下所示
Why maven puts all resources under the classes folder? 为什么Maven将所有资源都放在classes文件夹下? Is my folder structure wrong ? 我的文件夹结构不正确吗?
Let explain, briefly, maven behaviour 让我们简要地解释一下行家的行为
The stuff put in src/main/resources is supposed to be reachable from classpath. 放在src / main / resources中的东西应该可以从classpath到达。 So in case of web application it will be put in WEB-INF/classes 因此,在Web应用程序的情况下,它将被放在WEB-INF / classs中
The stuff put in src/main/webapp will be copied, as is, to in web application root 放入src / main / webapp的内容将原样复制到Web应用程序的根目录中
Maven is doing right but since you are using spring MVC youre resources are supposed to be a static resource and should be put under Maven做得很好,但是由于您使用的是Spring MVC,因此您的资源应该是静态资源,应该放在
main/webapp/resources 主/ web应用/资源
while your pages will be under 而您的页面将处于
main/webapp/WEB-INF/views 主/ web应用/ WEB-INF /视图
and should contains .html or .jsp pages 并且应包含.html或.jsp页面
now for main/resources are intended for configuation files such as persistence.xml or faces properties and any other that will be used for "java" classes. 现在,用于主要/资源的资源用于配置文件,例如persistence.xml或faces属性以及将用于“ java”类的任何其他文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.