mybatis configure and use

1, the configuration

 

 

 

 

 

 

 mybatis-config.xml file:

<? xml version = " 1.0 " encoding = " UTF-8 " ?> 
<DOCTYPE the Configuration the PUBLIC! " - // mybatis.org//DTD Config 3.0 // EN "  " http://mybatis.org/dtd/mybatis config.dtd--3 " > 
<-! fill in your mysql user name and password, as well as connection to add url " serverTimezone = GMT% 2B8? " or will be error -> 
<the Configuration> 
    <-! environment configuration ... -> 
    <the Properties Resource = " jdbc-prod.properties " /> 
    <Settings> 
        <-! other configurations ... -> 
        <setting name="mapUnderscoreToCamelCase" value="true"/>
        <!--其他配置...  -->
    </settings>
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC" />
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.cj.jdbc.Driver" />
                <property name="url" value="${database.url}" />
                <property name="username" value="${database.username}" />
                <property name="password" value="${database.password}" />
            </dataSource>
        </environment>
    </environments>
    <mappers>
        <mapper resource="mapper/ActionMapper.xml"/>
        <mapper resource="mapper/OperatorMapper.xml"/>
    </mappers>
</configuration>

 jdbc-dev.properties file:

database.url=jdbc:mysql://localhost:3306/demo?serverTimezone=GMT%2B8
database.username=root
database.password=

 

Guess you like

Origin www.cnblogs.com/lvchengda/p/12587446.html