Search code examples
javaapachevelocityservlet-3.0

Apache Velocity + Servlet 3.0


I'm upgrading from servlet 2.5 to 3.0, and I'm using Apache Velocity for templating, after a mvn dependency:tree I see velocity-tools depends on servlet-api:jar:2.3, there's a way to use servlet 3.0 with Apache Velocity?

Thanks in advance


Solution

  • I had the same problem; my Servlet 3.0 project wouldn't compile because servlet-api 2.3 was on the Maven classpath as a dependency of Velocity Tools.

    The work-around is to declare the Velocity dependency as runtime so at compile-time the project still builds with Servlet 3.0

    <dependency>
       <groupId>org.apache.velocity</groupId>
       <artifactId>velocity-tools</artifactId>
       <version>2.0</version>
       <scope>runtime</scope>
    </dependency>