找不到 org.springframework.boot:spring-boot-starter-velocity

Could not find org.springframework.boot:spring-boot-starter-velocity

我是 spring 的新手,正在尝试在 spring 启动时使用速度。

这是我的 build.gradle

repositories {
    mavenCentral()
}

plugins {
   id 'org.springframework.boot' version '2.0.4.RELEASE'
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'war'

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-velocity')
    runtime('org.springframework.boot:spring-boot-devtools')
    providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

当我通过 ./gradlew bootRun 同步时,它返回如下错误。

> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-velocity:.

您很可能忘记包含 Spring 的依赖管理插件。

apply plugin: 'io.spring.dependency-management'

还要确保您已指定要使用的 Spring 引导版本:

plugins { id 'org.springframework.boot' version '2.0.4.RELEASE' }

有关详细信息,请参阅 https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/gradle-plugin/reference/html/

Spring Boot 2.0 依赖于 Spring Framework 5.0。其中dropped support for Velocity。因此在 Spring Boot 2 中不再支持 Velocity。

如果您真的需要 Velocity,则必须坚持使用 Spring Boot 1.5。如果你可以转移到像 Freemarker 或 Mustache 这样的东西,你可能会更好地使用它。