mapper-locations和config-location作用是什么?什么時(shí)候需要配置?
mybatis:
? mapper-locations: classpath:mapper/*.xml
? config-location: classpath:config/mybatis-config.xml
mapper-locations和config-location作用是什么?什么時(shí)候需要配置?
自己曾經(jīng)做過(guò)的項(xiàng)目是這兩個(gè)都需要配置,這次就默認(rèn)寫(xiě)了兩個(gè),但是一直不能啟動(dòng)。后來(lái)發(fā)現(xiàn)與老師寫(xiě)的差了一個(gè)config-location,很詫異這個(gè)為什么不需要配置這個(gè)?求大神指導(dǎo)原因
2021-02-04
當(dāng)你需要使用mybatis-config.xml 配置文件的時(shí)候你就需要配置config-location,config-location的作用是確定mybatis-config.xml文件位置的,而mapper-locations是用來(lái)注冊(cè)你寫(xiě)的xxxmapper.xml文件。如果你使用了mybatis-config.xml,并且里面配置了mapper,那就不需要mapper-locations,