Apache Velocity + Servlet 3.0

我只是一个虾纸丫 提交于 2021-02-10 20:37:50

问题


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


回答1:


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>



回答2:


Maven dependencies don't mean I need exactly this version of the library, but almost I need at least this version. This means that if you declare a dependency on version 3.0 of the servlets library, that is the one that's going to be used.

And the 3.0 version of the servlets specification is backwards compatible with the 2.5 version, meaning that whatever Velocity needs from Servlets is going to be available.



来源:https://stackoverflow.com/questions/16311990/apache-velocity-servlet-3-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!