the XML definition. 1, create a new Com.kang.mapper package, define the map interface, interface name arbitrary, here is usermapper.
Package com.kang.mapper;
Import java.util.List;
Import Com.kang.pojo.User;
Public interface Usermapper {
//query user information based on User ID public username
finduserbyid (int id) throws Exception;
Query user list public
list2. Configuring the XML file Usermapper.xml
Note that the id attribute value in the configuration file
1. MapReduce Code EntryNew // sets the MapReduce input format job.waitforcompletion (true);2. InputFormat Analysis Public Abstract class Inputformat { // Gets the shard of the input file, is only a logical shard, and does not have a physical shard public Abstract list getsplits (jobcontext context); // Create Recordreader to read Data from Inputsplit Public Abstract Recordreader Createrecordreader (inputsplit split,taskattemptcontext context);}Different InputFormat will imp
Mybaits3 source code analysis (2): Scan Mapper to associate with spring IOC container, mybaits3ioc
First, let's talk about how mapper is configured to an object.
All interfaces that implement classes specified by markerInterface under basePackage will be scanned and parsed. Mapperscannerproceser implements the BeanDefinitionRegistryPostProcessor (BeanDefinitionRegistry postprocessor, think about Spring AOP
How to determine Mapper quantity for Hadoop-2.4.1 Learning
The advantage of MapReduce framework is that it can run mapper and reducer tasks in parallel in the cluster. How can we determine the number of mapper and reducer tasks, or how does Hadoop programmatically control the number of ER er and reducer started by jobs? In the
Intellij idea plug-in development-Quickly locate SQL IN THE mybatis mapper file and intellijmybatis
Intellij idea provides openApi, through which we can develop our own plug-ins to improve work efficiency. You can directly paste a link here to get started with the demo. http://www.jianshu.com/p/2427e4cfd3e9, you can also find it online .. I use intellij idea 2017 and jdk 1.8 or above.
Step 1: New project, select IntelliJ Plaltform Plugin,
Click Next,
testing the code we wrote.There are some problems with this development:There is a lot of duplicate code in the implementation class of the 1.dao interface, which increases the programmer's workload.2. In the implementation class, the Sqlsession method hard-encodes the statement ID (where "Test.finduserbyid" is the ID of statment) when invoking the SQL statement in the map file. 3. The variable passed in when the Sqlsession method is called, because the Sqlsession method uses generics, even
Currently MyBatis in addition to the SQL can be configured through XML, but also through the form of annotations to configure SQL, this article mainly describes how MyBatis is handling annotated SQL mapping, through the source code analysis processXML configurationParsing process private void Mapperelement (xnode parent) throws Exception {//If the Mapper node is configured in the configuration (parent! = NULL) { For (XNode Child:parent.getCh
When defining a Mapper interface (Userdao), we do not need to implement this class, but Sqlsession.getmapper () eventually returns an object that implements the interface. This object is implemented by MyBatis using the dynamic proxy of JDK. Here we will introduce the generation process of this proxy object and the implementation process of its method. The mapper code object's build Process Defaultsqlsessio
1, error message
caused By:org.apache.ibatis.builder.BuilderException:Error parsing Mapper XML. Cause:java.lang.IllegalArgumentException:Mapped statements Collection already contains value for Imageclassifytrain.countimageclassifytrain at Org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement (xmlmapperbuilder.java:120) at Org.apache.ibatis.builder.xml.XMLMapperBuilder.parse (xmlmapperbuilder.java:92) at Org.mybatis.spring.SqlSessionFac
Configuring log4j is relatively straightforward, such as logging of this mapper interface needs to be logged:Package Org.mybatis.example;public interface Blogmapper {@Select ("select * FROM blog WHERE id = #{id}") Blog Selectblog (int id);}As long as a file named log4j.properties is created in the app's classpath, the specific contents of the file are as follows:# Global Logging Configurationlog4j.rootlogger=error, stdout# MyBatis logging configuratio
Development specification:Mapper interface development method only need to program ape to write Mapper interface (equivalent to DAO interface),Dynamic proxy objects that are created by the MyBatis framework based on the interface definition.The method body of the proxy object is the same as the DAO interface implementation class method.Mapper interface development is subject to the following specifications:The namespace in the 1.mapper.xml file is the
Original address
Although MyBatis is very convenient, but want to write all the mapper still very tiring, fortunately mybatis the official introduction of automation tools, can be based on the database and the definition of a good configuration directly generated DAO layer and all the following code, very convenient.First WOM We build a maven project, I don't write it in detail here.Mybatis-generator Use configuration
Open the Pom.xml file and add 3
); SYSTEM.OUT.PRINTLN (user); }}
Configuration Mode 2Enable the spring scanner to comment out the original usermapper beanMapper Configuration Mapperfactorybean: Generate proxy objects based on mapper interface - - mapper batch scan, scan out the Mapper interface from the Mapper package,
Mybatis framework 3: dao layer development, Mapper dynamic proxy development, and mybatismapper
Here is the most basic building: http://www.cnblogs.com/xuyiqing/p/8600888.html
Next we achieve a simple addition, deletion, modification, query: http://www.cnblogs.com/xuyiqing/p/8601506.html
However, it is found that the code is too repetitive.
Next we will integrate and implement DAO development:
I. Original DAO development:
package dao;import pojo.Use
1, create the Mybatis-config.xml file, in the file to complete and database connection settings operationXML version= "1.0" encoding= "UTF-8"?>DOCTYPE configuration Public "-//mybatis.org//dtd Config 3.0//en" "Http://mybatis.org/dtd/mybatis-3-config.dtd">Configuration>PropertiesResource= "Db.properties"/>Typealiases>Two methods to use, it is recommended to use the second--PackageName= "Com.huawei.bean"/>Typealiases>EnvironmentsDefault= "Development">EnvironmentId= "Development">Configuring trans
Colleagues for help, said the restart of Debian, the system hangs.Report the following error```Loading, please wait .../dev/mapper/debian--vg-root contains a file system with Errors,check the file system./dev/mapper/debian-vg-root:Inodes that were part of a corrupted orphan linked list found./dev/mapper/debian--vg-root:unexpected inconsistency; RUN fsck manually.
Spring Mapper injection into service failed solution
Background: Some time ago in the research Springboot, and the company's small projects successfully used Springboot transformation, for the springboot of the agreement than the concept of configuration, it is agreed that the project structure and code more concise and elegant. This time is not too busy, so the project is ready to change, now the project with the company's traditional SSM, the projec
1. The configuration of the front controller Dispatcherservlet is configured in Web. XML to be the same as the servlet configuration1) contextconfiglocation configuration Sprimgmvc loaded configuration file (Configuration Processor mapper, adapter, etc.) if Contextconfiglocation is not configured, the default load is/web-inf/ Servlet name-servlet.xml (springmvc-servlet.xml)2)The first type: *.action, accessed with. Action ends resolved by Dispatcherse
1. Configure the note Mapper and adapter. -- Bean class="Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" /> -- Bean class="Org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" />However, in the actual development, the annotations of the adapter and mapper configuration is often used to note-driven:
Using Mvc:annotation-driven in
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.