gpt4 book ai didi

spring-mvc - 使用 Gradle 配置嵌入式 tomcat

转载 作者:行者123 更新时间:2023-11-28 22:34:19 25 4
gpt4 key购买 nike

我正在尝试运行 sample appSpring in action 中给出(第 4 版)但无法在 build.gradle 脚本中配置 tomcat,我尝试将 tomcat 插件放入脚本中

apply plugin: 'war'
apply plugin: 'idea'
**apply plugin: 'com.bmuschko.tomcat'**

dependencies {
compile "org.springframework:spring-webmvc:$springVersion"
compile "org.springframework:spring-jdbc:$springVersion"
compile "com.h2database:h2:$h2Version"
compile "org.hibernate:hibernate-validator:$hibernateValidatorVersion"
compile "org.apache.commons:commons-lang3:$commonsLangVersion"

compile "javax.servlet:jstl:$jstlVersion"
providedCompile "javax.servlet:javax.servlet-api:$servletApiVersion"
providedCompile "javax.servlet.jsp:jsp-api:$jspApiVersion"
providedCompile "javax.el:javax.el-api:$jspElVersion"

**classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'**

**def tomcatVersion = '7.0.59'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}"**

testCompile "junit:junit-dep:$junitVersion"
testCompile "org.springframework:spring-test:$springVersion"
testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
}

repositories {
maven { url 'http://maven.springframework.org/release' }
maven { url 'http://maven.springframework.org/milestone' }
maven { url 'http://maven.springframework.org/snapshot' }
maven { url 'http://download.java.net/maven/2' }
mavenCentral()
**jcenter()**
}

task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}

war {
baseName = 'spittr'
}

但它总是构建失败并给出错误:

Plugin with id 'com.bmuschko.tomcat' not found.

我在 ** 中封装了用于 tomcat 配置的设置。

最佳答案

阅读 the documentation for that plugin ,您需要在 gradle 构建的 buildscript 部分指定依赖项和存储库 - 这将在主构建脚本之前加载/构建。

删除文件中当前的插件和存储库,然后尝试将整个代码块添加到 gradle 的顶部:

buildscript {
repositories {
jcenter()
}

dependencies {
classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2'
}
}

关于spring-mvc - 使用 Gradle 配置嵌入式 tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31872475/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com