我试图在Spring中运行示例应用程序 (第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配置的设置。
I was trying to run sample app given in Spring in action(4th edition) but not able to configure tomcat with in build.gradle script,I have try to put the tomcat plugin with in script as
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' }But it always fails build giving error:
Plugin with id 'com.bmuschko.tomcat' not found.I have encapsulate settings in ** that I have used for tomcat configuration.
最满意答案
阅读该插件的文档 ,您需要在gradle构建的buildscript部分中指定依赖项和存储库 - 这将在主构建脚本之前加载/构建。
删除当前在文件中包含它们的插件和存储库,并尝试将整个代码块添加到gradle的顶部:
buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2' } }Reading the documentation for that plugin, you need to specify the dependency and the repository in the buildscript section of your gradle build - this will be loaded / built before the main build script.
Remove the plugin and repository as you currently have them in the file, and try adding this whole block of code to the top of your gradle:
buildscript { repositories { jcenter() } dependencies { classpath 'com.bmuschko:gradle-tomcat-plugin:2.2.2' } }更多推荐
发布评论