我與一個JEE項目,從Maven項目到動態Web。 問題是我沒有使用xml配置,但現在,我必須使用Dynamic web項目。春:Mongo的配置不能找到「蒙戈:庫」
我無法弄清楚如何正確書寫applicationContext.xml中;我讀過很多話題,但沒有人幫助我。
這裏的代碼和錯誤:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
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-4.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-4.2.xsd
http://www.springframework.org/schema/data/mongo
http://www.springframework.org/schema/data/mongo/spring-mongo.xsd">
<!-- Abilita l'uso di tutte le annotazioni -->
<context:annotation-config/>
<import resource="security-config.xml"/>
<context:component-scan base-package="it.**"/>
<!-- Abilita il supporto AOP -->
<aop:aspectj-autoproxy proxy-target-class="true"/>
<util:properties id="settings" location="classpath:../../META-INF/MANIFEST.MF"/>
<!-- i valori delle properties vengono iniettati in AuthentificationFilter e il id=myProps serve per l'iniezione -->
<util:properties id="myProps" location="classpath:muru/application.properties"/>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath*:muru/*.properties</value>
</list>
</property>
<property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg>
<bean class="com.mongodb.MongoClient">
<constructor-arg value="localhost"/>
<constructor-arg value="27017"/>
</bean>
</constructor-arg>
<constructor-arg value="database"/>
</bean>
<mongo:repositories base-package="it.cap.domain" mongo-template-ref="mongoTemplate"></mongo:repositories>
<!-- Abilita la configurazione delle transazioni tramite annotazioni -->
<tx:annotation-driven transaction-manager="txManager"/>
<bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/>
</beans>
堆棧跟蹤
11:12:26.108 [localhost-startStop-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 68 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 68; columnNumber: 93; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:repositories'.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'mongo:repositories'.
你能幫助我理解? 感謝諮詢:)
以及錯誤說,你在架構聲明錯誤,所以你必須要有無論是在相同的版本架構聲明或全部刪除的版本,然後Maven的更新,然後嘗試建立 – emotionlessbananas
是在你的包'* .domain'任何庫? – smsnheck
@smsnheck是的。 對於FlyingZombie,我會嘗試刪除版本,反正我從菜單不是「Maven的更新」(右鍵) – bigghe