Maven by Example - 5.6. Adding J2EE Dependencies |
|
To write a servlet, we’ll need to add the Servlet API as a dependency to the project’s POM. Add the Servlet 2.4 Specification as a Dependency. <project> [...] <dependencies> [...] <dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.4</version> <scope>provided</scope> </dependency> </dependencies> [...] </project>
It is also worth pointing out that we have used the Adding the JSP 2.0 Specification as a Dependency. <project> [...] <dependencies> [...] <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.0</version> <scope>provided</scope> </dependency> </dependencies> [...] </project>
Once you’ve added the Servlet specification as a dependency, run Note
[tobrien@t1 simple-webapp]$ mvn clean install ... [tobrien@t1 simple-webapp]$ mvn jetty:run [INFO] [jetty:run] ... 2007-12-14 16:18:31.305::INFO: jetty-6.1.6rc1 2007-12-14 16:18:31.453::INFO: No Transaction manager found 2007-12-14 16:18:32.745::INFO: Started SelectChannelConnector@0.0.0.0:8080 [INFO] Started Jetty Server At this point, you should be able to retrieve the output of the
~/examples/ch-simple-web $ curl http://localhost:8080/simple-webapp/simple SimpleServlet Executed |