Java Spring 3.0:“;前缀为;X";对于属性“;“是”;与元素类型“关联”;Z";“不受约束”;
直到今天早上,我的应用程序还可以正常工作,但在今天早上我重命名了我的Netbeans 6.9项目之后,我开始出现以下错误 我在构建Spring 3.0.4应用程序时遇到以下错误:Java Spring 3.0:“;前缀为;X";对于属性“;“是”;与元素类型“关联”;Z";“不受约束”;,java,xml,spring,xsd,Java,Xml,Spring,Xsd,直到今天早上,我的应用程序还可以正常工作,但在今天早上我重命名了我的Netbeans 6.9项目之后,我开始出现以下错误 我在构建Spring 3.0.4应用程序时遇到以下错误: The prefix "p" for attribute "p:driverClassName" associated with an element type "beans:bean" is not bound applicationContext.xml: <?xml version="1.0" encod
The prefix "p" for attribute "p:driverClassName" associated with an element type "beans:bean" is not bound
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:security="http://www.springframework.org/schema/security"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
<bean id="myEmf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="TT-SpringMVCPU"/>
</bean>
<bean id="configurationLoader"
class="org.springmodules.validation.bean.conf.loader.annotation.AnnotationBeanValidationConfigurationLoader"/>
<bean id="validator"
class="org.springmodules.validation.bean.BeanValidator"
p:configurationLoader-ref="configurationLoader"
p:errorCodeConverter-ref="errorCodeConverter"/>
<bean id="errorCodeConverter"
class="org.springmodules.validation.bean.converter.KeepAsIsErrorCodeConverter"/>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
p:basename="WEB-INF/errors"/>
<bean id="TT-SQLServer"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
p:driverClassName="net.sourceforge.jtds.jdbc.Driver"
p:url="jdbc:jtds:sqlserver://localhost:1234/TTToys"
p:username="sa"
p:password="Password1" />
</beans>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="TT-SpringMVCPU" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.sajee.TT.db.Categories</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.jdbc.url" value="jdbc:jtds:sqlserver://localhost:1234/TailSpinToys"/>
<property name="javax.persistence.jdbc.password" value="Password1"/>
<property name="javax.persistence.jdbc.driver" value="net.sourceforge.jtds.jdbc.Driver"/>
<property name="javax.persistence.jdbc.user" value="sa"/>
</properties>
</persistence-unit>
</persistence>
org.eclipse.persistence.jpa.PersistenceProvider
com.sajee.TT.db.Categories
假的
看到这里有什么不对劲吗?我对Netbeans没有任何经验,但我想问题可能与
p
命名空间的XML模式有关
这是胡乱猜测,但让我来猜。也许您已经将Netbeans配置为向其目录中添加自定义XSD,并指向项目中的XSD文件。重命名项目后,p
命名空间XML架构的路径无效
我甚至不知道这种XML目录配置在Netbeans中是否可行,我更喜欢Eclipse。我知道我迟到了,但我也犯了同样的错误,这可能对其他人有用。。我把
p:something
进入
试试这个:
<bean>
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<!-- and your others property -->
</bean>
您需要将名称空间添加到bean声明中 xmlns:c=”http://www.springframework.org/schema/c" xmlns:p=”http://www.springframework.org/schema/p" 请参阅spring文档参考
一切看起来都很好。命名空间p声明正确,“driverClassName”是有效的setter。是否有其他错误消息?@scheffield:已更新问题,但没有相关错误。这是从今天早上我重命名我的Netbeans 6.9项目时开始的。你有没有检查过问题是否出在p命名空间上:只需对DriverManager数据源使用老式语法,而不是p:.——这是因为我不相信p名称空间是您的问题的原因。我认为我们不会在代码中发现错误,因为它显然看起来像是某些Netbeans项目的错误配置。“无持久性提供程序”可能是由于类路径中缺少
/META-INF/persistence.xml
,以及缺少持久性提供程序实现造成的。p
-名称空间似乎是一些不必要的XML验证的结果。我不确定发生了什么,但可能是Netbeans出现了问题,因为在重新启动并进行了几次干净的构建之后,修复了该问题。谢谢大家的帮助。
p:something
<property name="something" value="anything_you_want_to_set"/>
p:driverClassName="net.sourceforge.jtds.jdbc.Driver"
<bean>
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<!-- and your others property -->
</bean>