【发布时间】:2015-08-08 11:25:30
【问题描述】:
我正在为执行返回的 DI 做一本书的简单示例:
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 [META-INF/spring/app-context.xml]
app-context.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="provider" class="com.apress.prospring4.ch2.HelloWorldMessageProvider"/>
<bean id="renderer" class="com.apress.prospring4.ch2.StandardOutMessageRenderer" p:messageProvider-ref="provider"/>
</beans>
之前的所有练习都运行良好... 没有 DI 的 bean 的外部附加练习也可以正常工作...... 使用 Spring 4.2、Maven 3、JVM 1.8。 有什么想法吗?
编辑我已将 p:notation 更改为
<bean id="renderer" class="com.apress.prospring4.ch2.StandardOutMessageRenderer">
<property name="messageProvider" ref="provider" />
</bean>
并删除了 p 命名空间引用,以便应用程序现在可以工作,这很好,因为我是那里的学习新手。
不过我一直想知道如何让 p 命名空间工作! 作为旁注,尽管我可以看到“http://www.springframework.org/schema/beans”,但我没有看到任何“http://www.springframework.org/schema/p”;可能是我缺乏知识。
【问题讨论】:
标签: spring dependency-injection maven-3