mapper-locations和config-location作用是什么?什么時候需要配置?
mybatis:
? mapper-locations: classpath:mapper/*.xml
? config-location: classpath:config/mybatis-config.xml
mapper-locations和config-location作用是什么?什么時候需要配置?
自己曾經做過的項目是這兩個都需要配置,這次就默認寫了兩個,但是一直不能啟動。后來發現與老師寫的差了一個config-location,很詫異這個為什么不需要配置這個?求大神指導原因
2021-02-04
當你需要使用mybatis-config.xml 配置文件的時候你就需要配置config-location,config-location的作用是確定mybatis-config.xml文件位置的,而mapper-locations是用來注冊你寫的xxxmapper.xml文件。如果你使用了mybatis-config.xml,并且里面配置了mapper,那就不需要mapper-locations,