Unable to locate Spring NamespaceHandler for XML schema namespace tp://www.springframework.org/schem
来源:互联网 发布:python salesforce 编辑:程序博客网 时间:2024/06/15 09:43
背景:
创建的ssm项目,在eclipse中通过main函数运行正常,如下, 即可以正常加载spring上下文。
/** * 加载spring配置文件和log4j日志文件 * @return boolean */ public boolean initEnv() { try { context = new ClassPathXmlApplicationContext("spring.xml"); logger.info("Init env successfully!"); return true; } catch (Exception e) { logger.error("Init env occur exception[{}].", e.getMessage()); return false; } }
通过maven打包后,通过java -jar运行,报如下错误:
7-09-11 22:18:02.777 [main] ERROR com.ilucky.alg.data.export.ProductExportManual - Init env occur exception[Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespacetp://www.springframework.org/schema/context]
解决方案如下, 在pom文件中加入如下配置:
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer>
完整的标签如下:
<build> <finalName>${project.artifactId}</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>2.3</version> <configuration> <createDependencyReducedPom>true</createDependencyReducedPom> <filters> <filter> <artifact>*:*</artifact> <excludes> <exclude>META-INF/*.SF</exclude> <exclude>META-INF/*.DSA</exclude> <exclude>META-INF/*.RSA</exclude> </excludes> </filter> </filters> <encoding>UTF-8</encoding> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" /> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.xxx.MainTest</mainClass> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.handlers</resource> </transformer> <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> <resource>META-INF/spring.schemas</resource> </transformer> </transformers> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addDefaultImplementationEntries>true</addDefaultImplementationEntries> </manifest> </archive> </configuration> </plugin> </plugins> </build>
阅读全文
1 0
- Unable to locate Spring NamespaceHandler for XML schema namespace tp://www.springframework.org/schem
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
- Unable to locate Spring NamespaceHandler for XML schema namespace 【http://www.springframework.org/schema/context】
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/s
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace[http://www.springframework.org/sch
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/sc
- 【spring-security】Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.sprin
- Unable to locate Spring NamespaceHandler for XML schema namespace
- Jquery事件、冒泡、委托与节点
- C++中char和int之间的联系
- Windows程序设计-菜单及其它资源
- springboot
- eclipse导入后报错的问题
- Unable to locate Spring NamespaceHandler for XML schema namespace tp://www.springframework.org/schem
- sort-colors
- hdu 3068 最长回文(manacher算法)
- HashMap简单实现
- Python3——列表基础
- elasticsearch学习过程中遇到的问题以及处理方式(持续更新...)
- 设计模式学习笔记(单例模式)
- springboot
- Luogu-2680 (二分答案+树上差分)