Common Java Cookbook

Edition: 0.19

Download PDF or Read on Scribd

Download Examples (ZIP)

9.5. Obtaining Velocity

9.5.1. Problem

You need to use Velocity to create templates that can reference variables and object properties and contain limited conditional and iterative control structures.

9.5.2. Solution

To use Velocity in a Maven 2 project, add the following dependency to your project's pom.xml:

Example 9.2. Adding a Dependency on Velocity

    <dependency>
        <groupId>org.apache.velocity</groupId>
        <artifactId>velocity</artifactId>
        <version>1.6.1</version>
    </dependency>

If you are not sure what this means, I'd suggest reading Maven: The Definitive Guide. When you depend on a library in Maven 2, all you need to do is add the dependency groupId, artifactId, and version to your project's dependencies. Once you do this, Maven 2 will download the dependency and make it available on your project's classpath.

9.5.3. See Also

To learn more about Velocity, visit the Velocity web site (http://velocity.apache.org/).


Creative Commons License
Common Java Cookbook by Tim O'Brien is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States License.
Permissions beyond the scope of this license may be available at http://www.discursive.com/books/cjcook/reference/jakartackbk-PREFACE-1.html. Copyright 2009. Common Java Cookbook Chunked HTML Output. Some Rights Reserved.