【转】解决高版本springboot对Velocity不支持

https://blog.csdn.net/sinat_31270499/article/details/82283880spring

最近在作关于Spring Boot开发的项目,由于项目中要用到Velocity的模板引擎,而如今新版本在官网上已经不支持Velocity了。apache

 

不能加入velocity相关的依赖spring-boot

在http://velocity.apache.org/download.cgi#engine上看到有相关的依赖jar包和配置信息,首先下载jar包:.net

 

下载的是:xml

engine-core velocity-engine-core-2.0.jar
下下来以后是这样一个东西:blog

 

而后在Idea中导入jar包,点击file中的project structure:模板引擎

而后选择modules中的dependencies,点击那个+号,找到你刚刚下载好的文件,就能够导入外部的jar包了。ci

由于当初官网初始化Spring的时候没有选择模板引擎,如今须要本身手动添加:开发

找到pom.xml文件,在<dependencies></dependencies>中间加入:get

 

文本格式:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-velocity</artifactId>
</dependency>

<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>

<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-tools</artifactId>
<version>2.0</version>
</dependency>
将Spring Boot的版本从Spring Boot 1.5.15改为1.4.0,这个版本支持Velocity。

 

改好后,保存,运行,若是你在运行以后能看到这样的一行,说明你已经成功的导入了velocity的依赖

 

而后就能够在网页中打开本身写的.vm模板文件了。

相关文章
相关标签/搜索