有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java配置休眠。cfg。春天的xml

我想休眠。cfg。xml文件与spring一起使用事务管理器。这是我的密码

冬眠。cfg。xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.connection.driver_class">
        com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
    <property name="hibernate.connection.url">
        jdbc:sqlserver://localhost\none:1433;databaseName=DATA</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password">1</property>
    <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
    <property name="hibernate.show_sql">true</property>
    <mapping resource="Model/TaiKhoan.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

账户。哈佛商学院。xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<!-- Generated Sep 16, 2016 11:24:56 AM by Hibernate Tools 4.3.1 -->
<hibernate-mapping>
    <class name="Model.TaiKhoan" table="TAI_KHOAN" schema="dbo" catalog="DATA" optimistic-lock="version">
        <id name="username" type="string">
            <column name="username" length="50" />
            <generator class="assigned" />
        </id>
        <property name="pass" type="string">
            <column name="Pass" length="50" />
        </property>
    </class>
</hibernate-mapping>

应用程序上下文。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: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-4.0.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
</beans>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
        <property name="mappingResources">
            <list>
                <value>Model.TaiKhoan</value>
            </list>
        </property>
    </bean>

但当我运行项目时,它无法运行。如何配置它们? 谢谢


共 (0) 个答案