Tomcat 无法将org.springframework.web.SpringServletContainerInitializer转换为javax.servlet.ServletContainerInitializer
试图通过gradle运行tomcatRun任务时出现此错误 显然,这是由依赖性问题引起的。我的Tomcat 无法将org.springframework.web.SpringServletContainerInitializer转换为javax.servlet.ServletContainerInitializer,tomcat,spring-mvc,gradle,Tomcat,Spring Mvc,Gradle,试图通过gradle运行tomcatRun任务时出现此错误 显然,这是由依赖性问题引起的。我的build.gradle文件粘贴在下面: apply plugin: 'war' apply plugin: 'tomcat' apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' //these create the 'provided' scope, mainly for the servlet dependen
build.gradle
文件粘贴在下面:
apply plugin: 'war'
apply plugin: 'tomcat'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
//these create the 'provided' scope, mainly for the servlet dependency
apply plugin: 'propdeps'
apply plugin: 'propdeps-maven'
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
buildscript {
repositories {
mavenCentral()
maven {
url "http://download.java.net/maven/2"
}
maven { url 'http://repo.spring.io/plugins-release' }
maven { url 'http://repo.spring.io/milestone/'}
}
dependencies {
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:0.9.8'
classpath 'org.springframework.build.gradle:propdeps-plugin:0.0.1'
}
}
repositories {
mavenCentral()
maven { url 'http://repo.spring.io/milestone/'}
}
dependencies {
def tomcatVersion = '7.0.42'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
compile 'org.springframework:spring-core:4.0.2.RELEASE'
compile 'org.springframework:spring-webmvc:4.0.2.RELEASE'
compile 'org.springframework.data:spring-data-jpa:1.5.1.RELEASE'
compile 'org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final'
compile 'org.hibernate:hibernate-entitymanager:4.3.4.Final'
compile 'postgresql:postgresql:9.1-901.jdbc4'
provided 'javax.servlet:javax.servlet-api:3.0.1'
runtime 'com.fasterxml.jackson.core:jackson-core:2.2.2'
runtime 'com.fasterxml.jackson.core:jackson-databind:2.2.2'
runtime 'javax.xml.bind:jaxb-api:2.2.9'
compile 'org.slf4j:slf4j-api:1.7.5'
runtime 'org.slf4j:slf4j-jdk14:1.7.5'
testCompile 'com.jayway.jsonpath:json-path:0.8.1'
testCompile 'com.jayway.jsonpath:json-path-assert:0.8.1'
testCompile 'org.springframework:spring-test:3.2.8.RELEASE'
testCompile 'junit:junit:4.+'
testCompile "org.mockito:mockito-all:1.9.5"
}
// tag::wrapper[]
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
// end::wrapper[]
tomcatRunWar.contextPath = ''
如何解决此错误?
spring数据jpa 1.5.1
所以至少存在一些冲突。
检查您的项目是否存在可能的冲突,特别是检查spring框架和ServletAPI是否存在依赖关系 通常,当servlet库添加到web应用程序类路径并与容器提供的类冲突时,会发生这种情况。