グローバルコンフィギュレーションファイル:MyBatisの-config.xmlに

二つのファイル:

     1)、グローバル・プロファイル:MyBatisの-config.xmlにいくつかのグローバルガイダンスセットの正しい動作をMyBatisの

     2)、SQLマッピングファイル:EmployeeDao.xmlはインターフェイスダオの実現の説明と同等です

詳細:

     1)、プロキシオブジェクトインターフェイスを取得、自動的に作成MyBatisの

     2)、SqlSessionFactoryとSQLSESSION。

          SqlSessionFactory SQLSESSIONは、オブジェクトの作成、ライン上の工場の唯一の新しいものを

          SQLSESSION:データベース接続および相互作用の同等、およびセッションのデータベース、新しいSQLSESSIONを作成する必要があります。



グローバルコンフィギュレーションファイル:MyBatisの-config.xmlに

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <!-- 配置连接池 -->
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.jdbc.Driver"/>
                <property name="url" value="jdbc:mysql://localhost:3306/mybatis_0325"/>
                <property name="username" value="root"/>
                <property name="password" value="root"/>
            </dataSource>
        </environment>
    </environments>

     <!-- mappers中注册我们所有写的dao接口的实现文件 -->
    <mappers>
        <!--resource:表示从类路径下找资源  -->
        <mapper resource="EmployeeDao.xml"/>
    </mappers>

</configuration>





データベースで大文字と小文字を区別しません












公開された434元の記事 ウォンの賞賛105 ・は 70000 +を見て

おすすめ

転載: blog.csdn.net/qq_39368007/article/details/104959945