Just started to learn the SSM framework, Mapper scan loading encountered some problems, finally solved.
In eclipse it is possible to scan mappings by placing Mapper.xml files and Mapper.java files under the same path, but idea is not possible,
Mapper Scan configuration is available in spring's configuration file Applicationcontext.xml
With this configuration, it is not necessary to load the mapper mapping file in the Sqlmapconfig.xml file.
As follows:
<!--configuration sqlsessionfactory--> class= "Org.mybatis.spring.SqlSessionFactoryBean" > <!-- Load MyBatis configuration file-- <property name= "configlocation" value= "Classpath:config/mybatis/sqlmapconfig.xml"/ > <!--data Source- <property name= "DataSource" ref= "DataSource"/> <!--mapper.xml Scanner <property name= "mapperlocations" value= "Classpath:config/mapper/*.xml"/> </bean> <!- -Mapper Scanner-- class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" > < Property Name= "Sqlsessionfactorybeanname" value= "sqlsessionfactory"/> <property name= "BasePackage" Value= "Com.youye.mapper"/> </bean>
When configuring Sqlsessionfactory, configure the Mapperlocations property to load the Mapper.xml file, and the Mapper scanner configuration is shown above.
The order of the two properties in the Mapper scanner cannot be exchanged, i.e. the sqlsessionfactorybeanname must be in front.
Backend Development-IDEA-SSM Framework-mapper Scan