IDEA新建mybatis-config.xml配置文件

在使用IDEA使用Mybatis时,在把mybatis所依赖的包通过Maven加载后,就要新建mybatis-config.xml配置文件。我以为是可以直接通过右键然后创建mybatis-config.xml文件,事实证明,我找不到(还是真的我找不到)。我们来把Mybatis-config.xml配置文件的模板配置到IDEA中,方便以后使用。

如果使用新建文件的方式

配置mybatis-config.xml到IDEA中

<?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>
    <properties resource=""></properties>
    <typeAliases>

        <package name=""/>
    </typeAliases>
    <environments default="development">
        <environment id="development">
        <transactionManager type="JDBC"></transactionManager>
        <dataSource type="POOLED">
            <property name="driver" value="${database.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>
    </mappers>

</configuration>

总结

这样在以后写Mbatis配置文件时就方便很多,直接右键新建就可以了。通过这样的配置,其他我们可以根据我们自己的需求,来配置方便我们编程的许多编程模板。包括映射器的模板也行。

猜你喜欢

转载自blog.csdn.net/m0_54864585/article/details/126384143
今日推荐