gpt4 book ai didi

tomcat - org.springframework.web.SpringServletContainerInitializer 无法转换为 javax.servlet.ServletContainerInitializer

转载 作者:行者123 更新时间:2023-11-28 22:58:43 33 4
gpt4 key购买 nike

尝试通过 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 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-data-jpa 1.5.1 depends on servlet-api 2.5

所以至少存在一些冲突。检查dependency tree对你的项目可能存在的冲突特别检查spring framework和servlet api是否有依赖关系。

关于tomcat - org.springframework.web.SpringServletContainerInitializer 无法转换为 javax.servlet.ServletContainerInitializer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22728251/

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