我已经使用 Maven 插件在 Eclipse IDE 中创建了一个 Web 应用程序,如图所示
我在那个项目中创建了一个 Servlet
pom.xml
生成的是
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>MTest</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MTest Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>MTest</finalName>
</build>
</project>
当我右键单击 pom.xml 并执行 Run as Maven Install
我在下面看不到我的 servlet 的类文件
C:\Users\sai\OfficeWSApril14\MTest\target\MTest\WEB-INF\classes
因此,它的投掷ClassNotFoundException
请让我知道我做错了什么
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MTest Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ MTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ MTest ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ MTest ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\sai\OfficeWSApril14\MTest\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ MTest ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.7.1:test (default-test) @ MTest ---
[INFO] Surefire report directory: C:\Users\sai\OfficeWSApril14\MTest\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
There are no tests to run.
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-war-plugin:2.1.1:war (default-war) @ MTest ---
[INFO] Packaging webapp
[INFO] Assembling webapp [MTest] in [C:\Users\sai\OfficeWSApril14\MTest\target\MTest]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\sai\OfficeWSApril14\MTest\src\main\webapp]
[INFO] Webapp assembled in [107 msecs]
[INFO] Building war: C:\Users\sai\OfficeWSApril14\MTest\target\MTest.war
[WARNING] Warning: selected war files include a WEB-INF/web.xml which will be ignored
(webxml attribute is missing from war task, or ignoreWebxml attribute is specified as 'true')
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ MTest ---
[INFO] Installing C:\Users\sai\OfficeWSApril14\MTest\target\MTest.war to C:\Users\sai\.m2\repository\com\MTest\0.0.1-SNAPSHOT\MTest-0.0.1-SNAPSHOT.war
[INFO] Installing C:\Users\sai\OfficeWSApril14\MTest\pom.xml to C:\Users\sai\.m2\repository\com\MTest\0.0.1-SNAPSHOT\MTest-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.536s
[INFO] Finished at: Mon Apr 29 10:10:06 IST 2013
[INFO] Final Memory: 5M/15M
[INFO] ---------------------
当我右键单击 Eclipse IDE Project create new Servlet 时,如何
确保源文件放在 src/main/java 下?
我附上了截图,请看