configuration.xml里:

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE configuration
    3. PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    4. "http://mybatis.org/dtd/mybatis-3-config.dtd">
    5. <configuration>
    6. <environments default="development">
    7. <environment id="development">
    8. <transactionManager type="JDBC"/>
    9. <dataSource type="POOLED">
    10. <property name="driver" value="com.mysql.jdbc.Driver"/>
    11. <property name="url" value="jdbc:mysql://localhost:3306/testmybatis?useSSL=false"/>
    12. <property name="username" value="root"/>
    13. <property name="password" value="root"/>
    14. </dataSource>
    15. </environment>
    16. </environments>
    17. <mappers>
    18. <mapper class="dao.StudentDao"/>
    19. </mappers>
    20. </configuration>

    原来的标签下的mapper里是resource,

    1. <mappers>
    2. <mapper resource="studentMapper.xml"/>
    3. </mappers>

    基于注解的话,标签就改成了class

    1. <mappers>
    2. <mapper class="dao.StudentDao"/>
    3. </mappers>

    如果没改过来,会报错:
    image.png