My goal is to rewrite the sessionFactory section of my xml file into the same format as all other areas in my xml file. I need to use the p-namespace to make things look consistent and neat. The problem that I ran into is using the util/p namespace.
感谢你让我赞扬这一职位。 这是我的整个Xml档案:
<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:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- DataSource Beans -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close"
p:url="jdbc:hsqldb:file:database.dat;shutdown=true"
p:driverClassName="org.hsqldb.jdbcDriver"
p:username="sa"
p:password="" />
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="mappingResources">
<list>
<value>/com/bookstore/domain/Book.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<!-- Template Beans -->
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"
p:dataSource-ref="dataSource" />
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"
p:sessionFactory-ref="sessionFactory" />
<!-- DAO Beans -->
<bean id="bookDao" class="com.bookstore.data.BookDao"
p:hibernateTemplate-ref="hibernateTemplate" />
<bean id="accountDao" class="com.bookstore.data.AccountDao"
init-method="createTable"
p:jdbcTemplate-ref="jdbcTemplate" />
<!-- Service Beans -->
<bean id="bookService" class="com.bookstore.services.BookService"
p:bookDao-ref="bookDao" />
<bean id="purchasingService" class="com.bookstore.services.PurchasingService"
p:bookServiceInterface-ref="bookService"
p:accountServiceInterface-ref="accountService" ></bean>
<bean id="accountService" class="com.bookstore.services.AccountService"
p:accountDao-ref="accountDao" />
<!-- AOP Advice Beans -->
<bean id="loggingAdvice" class="com.bookstore.advice.LoggingAdvice" />
<bean id="performanceTimingAdvice" class="com.bookstore.advice.PerformanceTimingAdvice" />
<!-- Auto Proxy -->
<aop:aspectj-autoproxy />
</beans>
This is what I have so far - using a combination of util:list and util:properties:
<util:list id="mappingResourcesList">
<value>/com/bookstore/domain/Book.hbm.xml</value>
</util:list>
<util:properties id="hibernatePropertiesProps">
<prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</util:properties>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
p:dataSource-ref="dataSource"
p:mappingResources-ref="mappingResourcesList"
p:hibernateProperties-ref="hibernatePropertiesProps" />
The error message that I m getting currently pertains to the util:list, but I m equally suspicious of my util:properties as well:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 22 in XML document from class path resource [application.xml] is invalid;
nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c:
The matching wildcard is strict, but no declaration can be found for element util:list .
What part of my util:list and util:properties must I change to get this to work?