【轉】解決高版本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模板文件了。

相關文章
相關標籤/搜索