Running a Spring web application
In this recipe, we will use the Spring web application from the previous recipe. We will compile it with Maven and run it with Tomcat.
How to do it…
Here are the steps to compile and run a Spring web application:
- In
pom.xml
, add this boilerplate code under theproject
XML node. It will allow Maven to generate.war
files without requiring aweb.xml
file:<build> <finalName>springwebapp</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.5</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build>
- In Eclipse, in the left-hand side pane Package Explorer, select the
springwebapp
project ...
Get Spring Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.