Friday, June 8, 2007

Build Struts 2 Application Using Maven 2

I really think that using Maven as tool to build Java Projects is simply great, but if there is one thing I hate is searching ibiblio for the dependencies I need for my project. So I will post below the path for the main components one will need to get started with Struts 2 on his project.

By default, Maven will look for the dependencies on its central repository It is possible to configure the repositories where you want maven to look up for files. These two below are some alternative repositories where you can try to find components you need. In the apache repository below is possible to find the SNAPSHOT version of the components.

Just add the code below into your pom file.

    <name>iBiblio Maven2 Repository</name>
    <name>Apache Repository</name>

Check the official Maven site about how to setup multiple repositories.

Now, we can reach for those components! :)
As advised by the struts team, the minimum set of components one might need is below.

  • struts2-core.jar

  • xwork.jar

  • ognl.jar

  • freemarker.jar

  • commons-logging.jar

Fortunately, to download all of them automagically, all you need to add to your pom files are the lines below:


Wanna do this even faster? Use maven archetypes to create a struts2-aware project! ;)

mvn archetype:create -DgroupId=tutorial \
    -DartifactId=tutorial \
    -DarchetypeGroupId=org.apache.struts \
    -DarchetypeArtifactId=struts2-archetype-starter \
    -DarchetypeVersion=2.0.5-SNAPSHOT \

1 comment:

Anonymous said...

Thanks for saving me time to setup maven