简体   繁体   English

我应该在Maven中的Web(WAR)项目中添加Java文件?

[英]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的其他人更容易识别和理解结构。

Source/Read more 来源/阅读更多

除非您在maven项目中的pom.xml (高效)Java源文件中明确指定它,否则请转到src/main/java

Java文件总是在src / main / java中,并建议保持这种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在哪里可以为Maven War项目添加类文件? - Where is a proper place to add class files for maven war project? 我应该在web应用程序(maven项目)中将java.util.logging的logging.properties文件放在哪里? - Where should I put logging.properties file for java.util.logging in web application (maven project)? 我应该将IDL文件和生成的代码放在Maven项目的哪里? - Where should I put IDL files and generated code in Maven project? Eclipse动态Web项目:我应该在哪里放置资源文件 - Eclipse dynamic web project : where should I put resource files 如何使用 maven 将 Java 项目的 python 文件包含到 .war 中? - How to include python files of Java project into .war with maven? 我应该将pdf放在Java Web应用程序项目中的哪里? - Where should I place a pdf to be download in a Java web app project? 我应该在Java项目的哪里设置前端文件? - Where should I set the frontend files in a Java project? 我应该将 SQL 文件放在我的 Java 项目中的什么位置? - Where should I put the SQL files in my Java project? 如何在一个Maven项目中打包多个WAR文件? - How do I package multiple WAR files in one Maven project? 我应该在maven项目的路径中放置不被视为资源的配置文件 - Where in maven project's path should I put configuration files that are not considered resources
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM