Maven2 pom.xml for a webapp that works in Eclipse Europa+m2eclipse


/ Published in: Java
Save to your folder(s)

1. mvn archetype:create -DgroupId=deng -DartifactId=mywebapp -DarchetypeArtifactId=maven-archetype-webapp
2. Replace web.xml with http://snipplr.com/view/3800/minimal-webxml-webapp-descriptor-version-24
3. Replace pom.xml in this snipplet.
4. mvn eclipse:m2eclipse -Dwtpversion=1.5
5. Import project into Eclipse
6. In project properties > Java Build Path. Add a "Server Runtime" Library ( with Tomcat6)
7. In project properties > J2EE Module Dependencies. Check Maven2Dependencies
8. Project > Clean

If you re-importing a project back into Eclipse, be sure to:
1. Delete your existing project in eclipse
2. mvn clean eclipse:clean
3. Repeat steps 4-8 above.


Copy this code and paste it in your HTML
  1. <project xmlns="http://maven.apache.org/POM/4.0.0"
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  4. <modelVersion>4.0.0</modelVersion>
  5. <groupId>deng.mywebapp</groupId>
  6. <artifactId>mywebapp</artifactId>
  7. <packaging>war</packaging>
  8. <version>1.0-SNAPSHOT</version>
  9. <name>mywebapp Maven Webapp</name>
  10. <url>http://maven.apache.org</url>
  11.  
  12. <profiles>
  13. <profile>
  14. <id>servlet</id>
  15. <activation>
  16. <activeByDefault>false</activeByDefault>
  17. </activation>
  18. <dependencies>
  19. <dependency>
  20. <groupId>javax.servlet</groupId>
  21. <artifactId>servlet-api</artifactId>
  22. <version>2.5</version>
  23. <scope>provided</scope>
  24. </dependency>
  25. <dependency>
  26. <groupId>javax.servlet.jsp</groupId>
  27. <artifactId>jsp-api</artifactId>
  28. <version>2.1</version>
  29. <scope>provided</scope>
  30. </dependency>
  31. </dependencies>
  32. </profile>
  33. </profiles>
  34. <dependencies>
  35. <dependency>
  36. <groupId>junit</groupId>
  37. <artifactId>junit</artifactId>
  38. <version>4.4</version>
  39. <scope>test</scope>
  40. </dependency>
  41. <dependency>
  42. <groupId>javax.servlet</groupId>
  43. <artifactId>jstl</artifactId>
  44. <version>1.1.2</version>
  45. </dependency>
  46. <dependency>
  47. <groupId>taglibs</groupId>
  48. <artifactId>standard</artifactId>
  49. <version>1.1.2</version>
  50. </dependency>
  51. </dependencies>
  52. <build>
  53. <finalName>mywebapp</finalName>
  54. <plugins>
  55. <plugin>
  56. <groupId>org.mortbay.jetty</groupId>
  57. <artifactId>maven-jetty-plugin</artifactId>
  58. </plugin>
  59. <plugin>
  60. <artifactId>maven-compiler-plugin</artifactId>
  61. <configuration>
  62. <source>1.5</source>
  63. <target>1.5</target>
  64. </configuration>
  65. </plugin>
  66. </plugins>
  67. </build>
  68. </project>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.