[英]Where should I add Java files in web (WAR) project in Maven?
Where should I have my Java source folder in the Maven web application architecture which results in a WAR? 我应该在Maven Web应用程序体系结构中将Java源文件夹放在哪里导致WAR?
Suggestions needed. 建议需要。
Maven web applications typically do not include java source code. Maven Web应用程序通常不包含Java源代码。 The maven approach is to create a maven project for the "logic" of your web application (this will build into a jar) and create a second maven project for the webapp portion of your web application (this will build into a war). maven方法是为Web应用程序的“逻辑”创建一个maven项目(这将构建到一个jar中),并为Web应用程序的webapp部分创建第二个maven项目(这将构建为一场战争)。 Then in the webapp portion, you introduce a dependency on the "logic" portion. 然后在webapp部分中,您将引入对“逻辑”部分的依赖。
The end result is that when you build / test your logic jar (which contains servlets, etc), you will deploy that to your local repository and then build your war (which contains jsp pages, web.xml configs, etc). 最终结果是,当您构建/测试逻辑jar(包含servlet等)时,您将把它部署到本地存储库,然后构建您的war(包含jsp页面,web.xml配置等)。
The basic structure that is standard for Maven project is the following. Maven项目标准的基本结构如下。
src/main/java Application/Library sources
src/main/resources Application/Library resource
src/main/filters Resource filter files
src/main/assembly Assembly descriptors
src/main/config Configuration files
src/main/webapp Web application sources
src/test/java Test sources
src/test/resources Test resources
src/test/filters Test resource filter files
src/site Site
Following the Maven recommendations and normal behavior makes it easier for other people familiar with Maven to easy recognize and understand the structure. 遵循Maven的建议和正常行为使熟悉Maven的其他人更容易识别和理解结构。
除非您在maven项目中的pom.xml
(高效)Java源文件中明确指定它,否则请转到src/main/java
。
Java文件总是在src / main / java中,并建议保持这种方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.