相关疑难解决方法(0)

"无法找到Spring NamespaceHandler"错误

我正在使用Spring创建一个独立的Sava应用程序来处理JDBC访问.该应用程序在每次测试中都能正常工作,我决定需要一个jar来部署我们的客户端.

他们的类路径中可能没有spring,所以我使用maven-assembly-plugin来处理带有依赖项的jar创建.

但是,当我尝试运行该应用程序时:

java -jar target/myproject-0.0.1-SNAPSHOT-jar-with-dependencies.jar
Run Code Online (Sandbox Code Playgroud)

这会引发以下错误:

Exception in thread "main" org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/p]
Offending resource: class path resource [applicationContext.xml]

at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
...and so on to the database access class of this project.
Run Code Online (Sandbox Code Playgroud)

applicationContext.xml文件位于projectbase/src/main/resources中.它放在目标/包名基础上.

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/context
   http://www.springframework.org/schema/context/spring-context-3.0.xsd">


    <bean id="dataSourceDesenv" class="org.apache.commons.dbcp.BasicDataSource"... />

    <bean id="simpleJdbcDaoSupport" class="org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport"
      p:dataSource-ref="dataSourceDesenv" />

    <bean id="simpleJdbcTemplate" class="org.springframework.jdbc.core.simple.SimpleJdbcTemplate">
        <constructor-arg ref="dataSourceDesenv" />
    </bean>

</beans>
Run Code Online (Sandbox Code Playgroud)

java spring maven-2

16
推荐指数
3
解决办法
2万
查看次数

无法找到XML架构命名空间的Spring NamespaceHandler

我在eclipse中运行tomcat中的一些servlet代码.它一直很好,但今天我得到了错误Unable to locate Spring NamespaceHandler for XML schema namespace.完整错误如下所示:

SEVERE: Allocate exception for servlet RunServlet
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration     problem: Unable to locate Spring NamespaceHandler for XML schema namespace     [http://www.springframework.org/schema/tx]
Offending resource: class path resource [spring/dao.xml]
Run Code Online (Sandbox Code Playgroud)

我已经看过有关此错误的其他问题,但我并不理解答案.

当我查看目标库时,我可以看到它spring-tx-3.0.5.RELEASE.jarWEB-INF/lib.

谁能帮我吗?

非常感谢!

编辑:dao.xml开始:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
          http://www.springframework.org/schema/tx
          http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
Run Code Online (Sandbox Code Playgroud)

编辑:不确定这是否相关,但我正在研究mac book pro,最新的mac更新更新到Java 1.6,我刚刚将我的Java首选项切换到1.6.

编辑:我也在Tomcat日志中收到以下消息,但我认为我以前收到它并且我认为它不相关,但以防万一:

INFO: Starting Servlet Engine: Apache Tomcat/7.0.14
Jul 6, 2011 11:59:55 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/Users/bw/Documents/workspace2/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/core/WEB-INF/lib/servlet-api-2.5.jar) - jar …
Run Code Online (Sandbox Code Playgroud)

java eclipse spring tomcat servlets

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×2

spring ×2

eclipse ×1

maven-2 ×1

servlets ×1

tomcat ×1