java 在 Maven 中处理 Web 项目的非常规源目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/224373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:30:23  来源:igfitidea点击:

Handling unconventional source directory for a web project in maven

javamaven-2

提问by ashitaka

I've inherited a web project (Servlets) which is currently build inside eclipse.

我继承了一个当前在 eclipse 中构建的 web 项目 (Servlets)。

I want to add maven around it. But the project's source directory is not following the maven convention. Instead of being inside src/main/java, it's src/package/name/...

我想在它周围添加 Maven。但是项目的源目录不遵循 maven 约定。它不是在 src/main/java 里面,而是 src/package/name/...

I don't want to change anything right now because they are working at full speed towards a milestone. Can I configure maven to accept src/ as the java source directory ? Thanks

我现在不想改变任何东西,因为他们正全速朝着一个里程碑努力。我可以将 maven 配置为接受 src/ 作为 java 源目录吗?谢谢

回答by sblundy

Just add this to your pom in the buildsection.

只需将此build部分添加到您的 pom 中即可。

<sourceDirectory>${basedir}/src</sourceDirectory>

Here's the relevant section of the POM doc on configuring the directories.

这是 POM 文档中有关配置目录的相关部分。