【发布时间】:2021-12-17 22:21:05
【问题描述】:
我的 xml 仅适用于 spring-mongo.xsd 架构的 version 1.8。当我尝试使用latest(当前为3.0)时,我得到了这些错误:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:mongo'. [11]
cvc-complex-type.3.2.2: Attribute 'mongo-ref' is not allowed to appear in element 'mongo:db-factory'. [12]
cvc-complex-type.3.2.2: Attribute 'username' is not allowed to appear in element 'mongo:db-factory'. [12]
cvc-complex-type.3.2.2: Attribute 'password' is not allowed to appear in element 'mongo:db-factory'. [12]
这是我的 xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo.xsd">
<mongo:mongo id="mongo" replica-set="${mongo.replicaset}" write-concern="${mongo.write_concern:REPLICAS_SAFE}"/>
<mongo:db-factory id="DbFactory" mongo-ref="mongo" dbname="${mongo.db}" username="${mongo.username}" password="${mongo.password}"/>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="DbFactory"/>
<property name="writeResultChecking" value="EXCEPTION"/>
</bean>
</beans>
根据其他答案,我尝试将credentials 属性与连接字符串一起使用,但即使这样也被拒绝了?
【问题讨论】: