package com.mybatis.dao;
import com.mybatis.model.Employee;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* Created by wanggenshen_sx on 2016/12/26.
*/
public interface EmployeeMapper {
@Select("select id,lastName,email from employee where id=#{id}")
Employee getEmployeeById(int id);
@Select("select * from employee")
List getAllEmployees();
}
2)实体类:Employee.java
package com.mybatis.model;
/**
* Created by wanggenshen_sx on 2016/12/23.
*/
public class Employee {
private int id;
private String lastName;
private String email;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public String toString() {
return "Employee [id=" + id + ", lastName=" + lastName + ", email="
+ email+" ]" ;
}
public Employee(){}
}
3) Service层:
创建EmployeeService接口
package com.mybatis.service;
import com.mybatis.model.Employee;
import java.util.List;
/**
* Created by wanggenshen_sx on 2016/12/26.
*/
public interface EmployeeService {
Employee getEmployee(int id);
List getEmployees();
}
创建EmployeeServiceImpl实现类:注意添加@Service注解
package com.mybatis.service;
import com.mybatis.dao.EmployeeMapper;
import com.mybatis.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Created by wanggenshen_sx on 2016/12/26.
*/
@Service
public class EmployeeServiceImpl implements EmployeeService {
public EmployeeServiceImpl() {
System.out.printf("init EmployeeServiceImpl");
}
@Autowired
private EmployeeMapper employeeMapper;
@Override
public Employee getEmployee(int id){
return employeeMapper.getEmployeeById(id);
}
public ListgetEmployees(){
return employeeMapper.getAllEmployees();
}
}
我在这里没有添加标签,spring无法初始化,出现了【Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeController': Unsatisfied dependency expressed through field 'employeeService': No qualifying bean of type [com.mybatis.service.EmployeeService] found for dependency [com.mybatis.service.EmployeeService]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: 】错误。
web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<context-param>
contextConfigLocationclasspath:spring-mybatis.xmlcontext-param>
org.springframework.web.context.ContextLoaderListenerorg.springframework.web.util.IntrospectorCleanupListenerspringmvc-servletorg.springframework.web.servlet.DispatcherServletcontextConfigLocationclasspath:springmvc-servlet.xml1springmvc-servlet/
spring JMS对于异步消息处理基本上只需配置下就能进行高效的处理。其核心就是消息侦听器容器,常用的类就是DefaultMessageListenerContainer。该容器可配置侦听器的并发数量,以及配合MessageListenerAdapter使用消息驱动POJO进行消息处理。且消息驱动POJO是放入TaskExecutor中进行处理,进一步提高性能,减少侦听器的阻塞。具体配置如下:
ZIP文件的解压缩实质上就是从输入流中读取数据。Java.util.zip包提供了类ZipInputStream来读取ZIP文件,下面的代码段创建了一个输入流来读取ZIP格式的文件;
ZipInputStream in = new ZipInputStream(new FileInputStream(zipFileName));
&n
Spring可以通过注解@Transactional来为业务逻辑层的方法(调用DAO完成持久化动作)添加事务能力,如下是@Transactional注解的定义:
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version
使用nginx lua已经两三个月了,项目接开发完毕了,这几天准备上线并且跟高德地图对接。回顾下来lua在项目中占得必中还是比较大的,跟PHP的占比差不多持平了,因此在开发中遇到一些问题备忘一下 1:content_by_lua中代码容量有限制,一般不要写太多代码,正常编写代码一般在100行左右(具体容量没有细心测哈哈,在4kb左右),如果超出了则重启nginx的时候会报 too long pa
import java.util.Stack;
public class ReverseStackRecursive {
/**
* Q 66.颠倒栈。
* 题目:用递归颠倒一个栈。例如输入栈{1,2,3,4,5},1在栈顶。
* 颠倒之后的栈为{5,4,3,2,1},5处在栈顶。
*1. Pop the top element
*2. Revers
仅作笔记使用
public class VectorQueue {
private final Vector<VectorItem> queue;
private class VectorItem {
private final Object item;
private final int quantity;
public VectorI