java - 获取“必须为元素类型“property”声明属性“ref”。
解决方案
下面是正确的 spring bean 配置应该是什么样子的 -
<?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-3.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/Banking"></property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id = "mysessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" ></property>
<property name = "mappingResources">
<list>
<value>credentials.hbm.xml</value>
</list>
</property>
<property name = "hibernateProperties">
<props>
<prop key="hibernate.hbm.ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="template" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="mysessionFactory"></property>
</bean>
<bean id="d" class="com.javatpoint.EmployeeDao">
<property name="template" ref="template"></property>
</bean>
</beans>
推荐阅读
- go - 地图上的 golang 类型断言令人恐慌
- windows - 如何用 Rust 捕获窗口退出按钮?
- ajax - DataTables 和 Ajax 使用错误“Uncaught TypeError: Cannot read property 'length' of undefined”
- javascript - 如何在树形图中切换单元格后调整 mxgraph 容器的大小并保留单元格位置?
- android - 在片段之间传递数据时,getArguments 返回 null
- r - 在矩阵中填充对角线和对角线+1
- docker - 在 Kubernetes 上安装仪表板
- javascript - 如何在传递给另一个组件的函数中获取 useState 变量的值
- javascript - 无法实现 React-table 服务器数据加载
- r - 如何添加计算另一列值的列