Eclipse:更改 Maven pom.xml 文件中的 webapp 文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13397202/
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
Eclipse: Change webapp folder in Maven pom.xml file
提问by gizmodus
Is it possible to define a different location for the webapp folder than the standard one ("/src/main/webapp/") in pom.xml? I know that you can define your web folder with
是否可以为 webapp 文件夹定义与 pom.xml 中的标准文件夹(“/src/main/webapp/”)不同的位置?我知道你可以定义你的 web 文件夹
<wb-resource deploy-path="/" source-path="/webapp"/>
in a file called "org.eclipse.wst.common.component". The problem is when I click Maven -> Update Project, this line is overwritten with the standard
在名为“org.eclipse.wst.common.component”的文件中。问题是当我单击 Maven -> Update Project 时,此行被标准覆盖
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
And then I have problems testing my project with Tomcat7 within Eclipse. I'm very thankful for every hint.
然后我在 Eclipse 中使用 Tomcat7 测试我的项目时遇到问题。我非常感谢每一个提示。
回答by yorkw
Answers in How to configure custom maven project structureare sufficient for a purely Maven build, i.e. from commandline. When import the project into Eclipse (via m2e), you need tell m2e a little bit more so that it can create and maintain the project structure properly within Eclipse.
如何配置自定义 Maven 项目结构中的答案对于纯 Maven 构建(即从命令行)来说就足够了。当将项目导入 Eclipse(通过 m2e)时,您需要告诉 m2e 多一点,以便它可以在 Eclipse 中正确创建和维护项目结构。
Actually, from Eclipse's perspective, it doesn't really care about how your project folder structure looks like, as long as the webapp folder is declared as a source folder or inside a source folder, however, by modifying .classpath doesn't make much sense as it's a auto-generated file and changed quite often.
实际上,从 Eclipse 的角度来看,它并不真正关心您的项目文件夹结构是什么样子,只要将 webapp 文件夹声明为源文件夹或在源文件夹中即可,但是,通过修改 .classpath 并没有太大作用感觉因为它是一个自动生成的文件并且经常更改。
It is highly recommended to obey the convention if you are able to, if not, using the following configuration for your customization:
如果您能够(如果不能)使用以下配置进行自定义,则强烈建议遵守约定:
<build>
<resources>
<resource>
<directory>${basedir}/webapp</directory>
</resource>
... ...
</resources>
... ...
</build>