简体   繁体   English

Apache Velocity + Servlet 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? 我正在从servlet 2.5升级到3.0,并且正在使用Apache Velocity进行模板制作,在mvn依赖关系之后:tree,我看到Velocity-tools依赖于servlet-api:jar:2.3,有一种在Apache上使用servlet 3.0的方法速度?

Thanks in advance 提前致谢

Maven dependencies don't mean I need exactly this version of the library , but almost I need at least this version . Maven依赖并不意味着我需要的正是这种版本的库 ,但几乎我需要至少这个版本 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. 这意味着,如果您声明对Servlets库的版本3.0有依赖性,那么将使用该依赖性。

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. Servlet规范的3.0版本向后兼容2.5版本,这意味着Servlet所需的任何Velocity都将可用。

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. 我的Servlet 3.0项目无法编译,因为Servlet-api 2.3作为Velocity Tools的依赖项位于Maven类路径上。

The work-around is to declare the Velocity dependency as runtime so at compile-time the project still builds with Servlet 3.0 解决方法是将Velocity依赖项声明为runtime因此在编译时,该项目仍使用Servlet 3.0构建

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM