- Download and install Maven
- Go the command line run:
mvn archetype:generate
- Follow the prompted steps - choosing the simple java web project (18) and a suitable name.
- When it is finished run:
mvn eclipse:eclipse
- Start Eclipse. Choose File -> Import -> Existing project. Select the directory where you ran the mvn goals.
- That's it you should now have a very good start to a war project in eclipse
- You can create the war itself by running mvn package or deploy it by
setting up a server in eclipse and simply adding adding the project to
the server.
Sample Configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-alpha-2</version>
<configuration>
<outputDirectory>${project.build.directory}/tmp/</outputDirectory>
<workDirectory>${project.build.directory}/tmp/war/work</workDirectory>
<webappDirectory>${project.build.webappDirectory}</webappDirectory>
<cacheFile>${project.build.directory}/tmp/war/work/webapp-cache.xml</cacheFile>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>pdf</nonFilteredFileExtension>
<nonFilteredFileExtension>png</nonFilteredFileExtension>
<nonFilteredFileExtension>gif</nonFilteredFileExtension>
<nonFilteredFileExtension>jsp</nonFilteredFileExtension>
</nonFilteredFileExtensions>
<webResources>
<resource>
<directory>src/main/webapp/</directory>
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</webResources>
<warName>Application</warName>
</configuration>
</plugin>
if you want to go with maven is to stick to maven conventions and particularly the Maven Directory Layout.
A simple war project would have the following directory layout:
No comments:
Post a Comment