I want to use interface instead of mapper XML file in MyBatis. In the MyBatis configuration file I define mapper
<mapper class="aa.B" /> where B contains methods annotated with MyBatis annotations. When I try to create a mapper instance session.getMapper(B.class); I get an error:
org.xml.sax.SAXParseException: Attribute “class” must be declared for element type “mapper”.
How can I use interfaces to map SQL statements here?
You can’t add Mapper Interface via the sqlconfig xml file, you’ve to use the Java API
The node in sqlconfig xml is for definding sqlmap XMLs, not Mapper Interfaces.
Or you could use mybatis-spring, which has support to auto add all the mappers in a said package, to the sqlsessionfactory’s configuration.