This guide is designed to get you up and running quickly.
Creating the project
First, you'll need to download and install maven2 if you haven't already done so. You *don't* have to use Maven, but it makes things substantially easier by managing all of the dependencies in Trails, and - take my word for it - for you as well. Even if you hit some minor problems with Maven, it saves you a lot of time as your project gets bigger.
|
If you are not familiar with maven, here are some links that'll help you get the knowledge you need to use it with Trails: |
Next, issue the following command (on a single line):
mvn archetype:create -DarchetypeGroupId=org.trailsframework \
-DarchetypeArtifactId=trails-archetype \
-DarchetypeVersion=1.2.1 \
-DgroupId=<your package> \
-DartifactId=<your project>
This will download the Trails archetype and any plugins needed. It will then create a working Trails project.
Running the project
Starting up your application is super simple, just go into your new project directory and do:
mvn jetty:run
or
mvn tomcat:run
This will download all dependencies, build your project and start it inside a jetty (or tomcat) container. Be warned, this can take a long time, especially if you just started using maven. If any downloads fail, try running this again. Sometimes the maven repositories get bogged down. When everything finishes, you will now be able to go to http://localhost:8080/
Import your project
Setting up an Eclipse project is also very simple. First, you will need to tell Eclipse how to find your maven repository. This is a one time step for each Eclipse workspace:
mvn -Declipse.workspace=<path-to-eclipse-workspace> eclipse:add-maven-repo
Now do:
mvn eclipse:eclipse
You should now be able import your project into Eclipse and ready to add your own domain classes!

Comments (2)
Feb 15, 2008
Tom Cook says:
I am new to Maven, so I am likely doing something dumb. I have downloaded ...I am new to Maven, so I am likely doing something dumb. I have downloaded and unpacked Maven 2.0.8, added the M2, M2_HOME variables to my environment and set PATH correctly so that mvn is found. When I do this:
I get the following output:
It seems that the trails-archetype component is not being downloaded from the Maven repository. Any idea why? Note that, in the above example, I have already run maven previously, so it didn't need to download all the usual maven components.
Feb 19, 2008
Kalle Korhonen says:
Sorry for the trouble Tom. Unfortunately, you happened to try Maven exactly at a...Sorry for the trouble Tom. Unfortunately, you happened to try Maven exactly at a wrong moment. There was a newer alpha-quality archetype plugin released just a few days before, and it completely broke the current archetypes. Run the command again with
Note how the version of the archetype plugin itself is specified. The syntax is ugly, sorry, but it's Maven (archetype plugin problem). More info at http://www.nabble.com/Not-founding-standart-archetypes-td15515118s177.html.