3

我在 eclipse 下有一个 Maven 应用程序。jsp 页面和 WEB-INF 文件夹位于路径 NomeMiaApplicazione\src\main\webapp 下。我在应用程序的根文件夹下运行这些命令: mvn clean 、 mvn eclipse: eclipse 和 mvn compile ,在所有三种情况下,构建都是成功的。但是,当我访问文件夹(进入工作区)。metadata.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps\NomeMiaApplicazione,没有jsp页面。这个问题的解决方案是什么?谢谢!

4

2 回答 2

1

It is necessary to clarify the role of the commands you used and their impact on Eclipse.

The mvn eclipse:eclipse command creates the Eclipse project files, in order to save you the hassle of configuring a new project and identifying all the sources for it. This command is also equivalent to creating a new Eclipse project from an existing Maven project using the m2e Eclipse plugin. See also this page regarding the eclipse:eclipse command. That being said, you only need to run such command once, and then import the resulting project into Eclipse.

Secondarily, mvn compile builds your source files into the target directory of your NomeMiaApplicazione root folder. This command does not involve Eclipse in any way. Also, web resources are still not packaged. To package them, you need to issue mvn package: you will then find the <artifact>-<version>.war file again under target, and the pre-packaged content under target\<artifact>-<version>. Beware that, in order to account for the webapp content, your Maven packaging must be of type war. Check the pom.xml for the <packaging> tag.

Finally, deployment is still another issue. If you actually need to move your .war file from the target directory to somewhere else (namely, an autodeploy folder of a servlet container), you can configure the Maven Deploy Plugin and issue mvn deploy. I'd rather suggest you to search SO for deploy war eclipse and/or deploy war maven, since there's plenty of related stuff. In the first case, you will find how to use Eclipse as a facility for deployment, while the second case leverages the command line to provide a more portable/flexible deployment procedure.

于 2012-06-19T10:48:48.520 回答
0

That's because mvn compile ends on compile phase of Maven's default lifecycle. Do mvn package and check then. And by the way, default Maven output directory is target so rather check it instead of kind of WTP temporary dirs.

于 2012-06-19T10:48:58.917 回答