Type interface is a known to the Mapperregistry solution

Source: Internet
Author: User
Tags relative

Experience tells us that this error is due to configuration file missing configuration ~ ~ ~

Add the following configuration to the MyBatis:

<mappers>
  <mapper resource= "Org/mybatis/builder/authormapper.xml"/>
  <mapper resource= "org /mybatis/builder/blogmapper.xml "/>
  <mapper resource=" Org/mybatis/builder/postmapper.xml "/>
</mappers>


It's also possible that:


To extend:

Mapper (mappers)

Now that MyBatis's behavior has been configured by the above elements, we need to define the SQL mapping statement. But first we need to tell MyBatis where to find these statements. Java does not provide a good way to find this automatically, so the best way is to tell MyBatis where to find the mapping file. You can use resource references relative to the classpath, or fully qualify the resource locator (including the URL of the file:///), or the class name and package name. For example:


<!--Using classpath Relative Resources-<mappers> <mapper resource= "org/mybatis/builder/ Authormapper.xml "/> <mapper resource=" Org/mybatis/builder/blogmapper.xml "/> <mapper resource=" org/ Mybatis/builder/postmapper.xml "/> </mappers> 
<!--Using URL fully qualified paths-
<mappers>
  <mapper url= "file:///var/mappers/ Authormapper.xml "/>
  <mapper url=" File:///var/mappers/BlogMapper.xml "/> <mapper url=
  " file:/// Var/mappers/postmapper.xml "/>
</mappers>
<!--Using Mapper interface Classes-
<mappers>
  <mapper class= " Org.mybatis.builder.AuthorMapper "/>
  <mapper class=" Org.mybatis.builder.BlogMapper "/>
  < Mapper class= "Org.mybatis.builder.PostMapper"/>
</mappers>
<!--Register all interfaces in a package as mappers--
<mappers>
  <package name= " Org.mybatis.builder "/>
</mappers>
The above methods 1 and 2 are XML definitions, and 3 and 4 are annotation definitions


XML definitions are commonly used in a way that uses the following:

<select id= "Testmybatisworks" resulttype= "Java.util.HashMap" >
		 <![ cdata[  
		    {call pqueryasyncnoticelist (
				    #{0,mode=in,jdbctype=integer}
			    )
		    }  
		]]>  
	</ Select>

The annotations are:

/**
	 * "proc list" with stored procedure query get list
	 * @param asyncstatus
	 * @return
	 *
	/@Select ("Exec pqueryasyncnoticelist #{asyncstatus} ")
	@Options (statementtype=statementtype.callable)
	list<map<string, object>> GetList2 (int asyncstatus);

The moment Rose Posture ~ ~ ~ Roar roar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.