spring-mybatis MapperScannerConfigurer,注解方式 (数据库持久化四)

主流方式

xml配置





	
		
		
		
		
	
	
		
		
	
	
		
		
		
	




	
	
		
	
	
		
	

重要代码说明

@Repository为必要,因为代表着显示扫描的意思

@Repository
public interface RoleMapper {
	void insertRole(Role role);
	Role selectRole(int id);
}

测试

public class TestMapperScanner {
	
	private static final Logger logger = LoggerFactory.getLogger(TestMapperScanner.class);
	
	public static void main(String[] args) {
		ApplicationContext context = new ClassPathXmlApplicationContext("spring-mybaties3.xml");
		RoleMapper roleMapper = context.getBean(RoleMapper.class);
		Role role = roleMapper.selectRole(10086);
		
		logger.debug(role.toString());
	}

}

你可能感兴趣的:(spring)