加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – Spring配置:无法找到Spring NamespaceHandler

发布时间:2020-12-15 04:30:00 所属栏目:Java 来源:网络整理
导读:配置问题:无法找到 XML架构命名空间的 Spring NamespaceHandler [ http://www.springframework.org/schema/tx] Offending resource:ServletContext resource [/WEB-INF/spring-servlet.xml] 解决方法 在gradle中,您可以使用shadowJar插件来修复它.我的编译
配置问题:无法找到 XML架构命名空间的 Spring NamespaceHandler [ http://www.springframework.org/schema/tx] Offending resource:ServletContext resource [/WEB-INF/spring-servlet.xml]

解决方法

在gradle中,您可以使用shadowJar插件来修复它.我的编译胖jar的build.gradle文件:

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'application'

mainClassName = 'ru.antowka.Initializer'

buildscript {
    repositories { jcenter() }
    dependencies {
        classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.2'
    }
}

jar {
    manifest {
        attributes 'Main-Class': mainClassName
    }
}

shadowJar {
    mergeServiceFiles('META-INF/spring.*')
}

// JDK 8
sourceCompatibility = 1.8
targetCompatibility = 1.8

compileJava.options.encoding = 'UTF-8'

repositories {

    maven {
        url 'http://repo.spring.io/snapshot'
    }

    mavenLocal()
    mavenCentral()
    jcenter()
}

dependencies {
    compile 'org.jsoup:jsoup:1.8.3'
    compile 'org.springframework:spring-context:4.2.2.BUILD-SNAPSHOT'
    compile 'log4j:log4j:1.2.17'
    compile 'org.quartz-scheduler:quartz:1.8.6'
    compile 'org.springframework:spring-support:2.0.8'
    compile 'org.springframework:spring-tx:2.5.4'
    compile 'org.springframework:spring-orm:4.1.7.RELEASE'
    compile 'org.hibernate:hibernate-core:4.3.10.Final'
    compile 'org.postgresql:postgresql:9.4-1201-jdbc41'
    compile 'org.apache.commons:commons-dbcp2:2.1'

    testCompile 'org.springframework:spring-test:4.2.0.RELEASE'
    testCompile 'org.mockito:mockito-core:1.+'
    testCompile 'junit:junit:4.12'
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读