首先明白,spring的IOC功能需要是利用反射原理,反射获取类的无参构造方法创建对象,如果一个类没有无参的构造方法spring是不会创建对象的。在这里需要提醒一下,如果我们在class中没有显示的声明构造方法,默认会生成一个无参构造方法,但是当我们显示的声明一个有参构造方法的时候,JVM不会帮我们生成无参构造方法,所以我们声明一个带参数的构造方法也需要声明一个无参构造方法。(题外话:如果父类声明一个有参构造方法,子类需要在构造方法第一行显示的调用父类构造方法,因为子类的对象也是父类的对象,所以在创建子类对象的同时也会创建父类的对象,如果父类有默认的无参构造函数,JVM会调用无参构造函数,但是有了有参的就需要我们在子类的构造函数中调用父类的有参构造函数)

1.Person类只有一个有参构造方法,报错如下:

No default constructor found; nested exception is java.lang.NoSuchMethodException: zd.dms.job.ebuy.Person.<init>()

2.大体知道有三种生命周期回调方法去参与到spring的生命周期,查阅了一下如下:(创建和销毁的执行顺序也是下面顺序)

  • 在指定方法上加上@PostConstruct 或@PreDestroy注解来制定该方法是在初始化之后还是销毁之前调用。
  • 通过实现 InitializingBean/DisposableBean 接口来定制初始化之后/销毁之前的操作方法;
  • 通过 <bean> 元素的 init-method/destroy-method属性指定初始化之后 /销毁之前调用的操作方法;

3.测试spring的顺序与注入的顺序与单例多例的问题

1.Person.java

package zd.dms.job.ebuy;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy; import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import zd.dms.dao.ebuy.GroupDao; public class Person implements InitializingBean,DisposableBean{
private String name; @Autowired
private GroupDao groupDao; public Person() {
System.out.println("---------------实例化一个Person对象----------");
System.out.println("---------------groupDao is -----------"+groupDao);
} public void init() {
System.out.println("------------这是xml的init方法----------....");
System.out.println("---------------groupDao is -----------"+groupDao);
} public void destory() {
System.out.println("---------------这是xml的destroy方法....");
System.out.println("---------------groupDao is -----------"+groupDao);
} @PostConstruct
public void init2() {
System.out.println("------------这是@PostConstruct的init方法----------....");
System.out.println("---------------groupDao is -----------"+groupDao);
} @PreDestroy
public void destory2() {
System.out.println("---------------这是@PreDestroy的destroy方法....");
System.out.println("---------------groupDao is -----------"+groupDao);
} @Override
public void destroy() throws Exception {
System.out.println("-----------这是DisposableBean的destroy方法....");
System.out.println("---------------groupDao is -----------"+groupDao);
} @Override
public void afterPropertiesSet() throws Exception {
System.out.println("-------这是InitializingBean的afterPropertiesSet方法....");
System.out.println("---------------groupDao is -----------"+groupDao);
}
}

 -----------------------单例模式的xml配置以及结果---------------------------------------:

配置:

    <bean id="person" class="zd.dms.job.ebuy.Person" autowire="byType" destroy-method="destory" init-method="init"></bean> 

测试:将Person类注入到Action我们访问Action

@Namespace("/qlqTest")
@SuppressWarnings("all")
public class TestAction extends DMSActionSupport { @Autowired
private Person person;
/**
*
*/
private static final long serialVersionUID = -8934360924125349297L; @Autowired
private GroupAndUserService groupAndUserService; private Map resultMap; @Action("test")
public String testAction() {
person.getClass();
return "js";
}
}

当我们第一次访问该Action会创建Person对象,打印结果如下:

- ---------------实例化一个Person对象----------
---------------groupDao is -----------null
------------这是@PostConstruct的init方法----------....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
-------这是InitializingBean的afterPropertiesSet方法....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
------------这是xml的init方法----------....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3

证明对象创建的顺序:

    构造器-->自动注入-->@PostConstrut-->InitializingBean-->xml中配置init方法    

再次调用不会打印,证明默认是单例的  singleton,也就是无论我们访问多少次Action,Spring容器中只有一个这个Person实例对象。

销毁的时候的结果:

---------------这是@PreDestroy的destroy方法....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
-----------这是DisposableBean的destroy方法....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
---------------这是xml的destroy方法....
---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3

所以销毁顺序为:

  @PreDestroy--DisposableBean-->xml中destroy-method方法

 -----------------------多例模式的xml配置以及结果---------------------------------------:

配置:

<bean id="person" class="zd.dms.job.ebuy.Person" autowire="byType" destroy-method="destory" init-method="init" scope="prototype"></bean>

我们多次访问Action,所以Action会多次调用Person对象,发现会多次创建Person对象,也就是请求一次会创建一个对象,也就是多例:

至于到底是该使用单例还是多例,这就需要我们平时的业务需求了,springMvc就是单例的,struts2默认就是多例的。我们也可以使用注解配置单例和多例,如下:

---------------------为了理解上面的单例多例的例子,继续测试---------------------

1.单例多例的对象创建问题

1.测试 action-service-dao是多-单-单 模式

Action:

package cn.qlq.action;

import java.util.HashMap;
import java.util.Map; import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import com.opensymphony.xwork2.ActionSupport; import cn.qlq.service.UserService; @Namespace("/")
@ParentPackage("default")
@Controller("firstAction")
@Results({ @Result(name = "redirect", location = "/index2.jsp", type = "redirect"),
@Result(name = "forward", location = "/index.jsp"),
@Result(name = "json", type = "json", params = { "root", "responseMap" }) })
public class UserAction extends ActionSupport { private Map<String, Object> responseMap = new HashMap<String, Object>(); @Autowired
private UserService userService; public UserAction() {
System.out.println("-----call UserAction 无参构造方法");
} @Action("saveUser")
public String saveUser() {
userService.saveUser();
return "json";
} public Map<String, Object> getResponseMap() {
return responseMap;
} public void setResponseMap(Map<String, Object> responseMap) {
this.responseMap = responseMap;
} }

Service:

package cn.qlq.service;

public interface UserService {
public void saveUser();
}
package cn.qlq.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import cn.qlq.dao.UserDao; @Service
public class UserServiceImpl implements UserService { @Autowired
private UserDao userDao; public UserServiceImpl() {
System.out.println("----- call UserServiceImpl 无参构造方法");
} @Override
public void saveUser() {
userDao.saveUser();
} }

Dao:

package cn.qlq.dao;

public interface UserDao {

    public void saveUser();
}
package cn.qlq.dao;

import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl implements UserDao { public UserDaoImpl() {
System.out.println("-----call UserDaoImpl 无参构造");
} @Override
public void saveUser() {
try {
Thread.sleep(4 * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("----user dao (save user)---");
} }

启动服务,查看控制台:(证明容器启动创建对象)

多次访问Action查看控制台:

 总结:

Action是struts默认多例:(注入Person类对象)

service层,默认是单例(注入GroupDaoImpl对象)

dao层默认也是单例,所以我们在多次访问的时候容器只创建Action层对象,并将Service与dao存在的对象注入进去。也就是容器有多个Action对象,但是只有一个Service、一个Dao对象。

也就是我们上面的配置从Action到service到dao的作用域是多-单-单,:

2.测试 action-service-dao是多-单-多 模式

修改DaoImpl配置:

多次访问Action查看控制台:

总结:对于多-单-多的模式依旧是容器有多个Acction,一个service,一个dao对象。因为容器在创建action的时候在容器中可以找到service对象、且service是单例对象,所以不会创建service对象,也就不会创建dao对象。

3.测试 action-service-dao是多-多-多 模式

将service也修改为多例:

多次访问Action查看控制台:

总结:对于多-多-多 模式,每次创建Action之后由于要注入service对象,service也是多例,所以会创建service对象,创建service注入dao对象,dao对象也是多例,所以会创建dao对象。也就是每个请求action到dao都会创建新对象。

4.测试 action-service-dao是多-多-单 模式

重新将dao设为单例:

多次访问Action:

总结:

  对于多-多-单 模式,每次创建Action之后由于要注入service对象,service也是多例,所以会创建service对象,创建service注入dao对象,dao对象是单例,所以不会创建dao对象。也就是每个请求action予service都会创建新对象,dao不会创建新对象。

2.测试单例多例的线程安全问题(dao与service层单例存在线程安全问题)

1.测试多-单-单模式

  Struts默认是多例,所以我们测试普通开发情况下的多-单-单的问题,假设dao有一成员变量,我们多个访问同时修改成员变量的值,查看结果:

dao的代码:

package cn.qlq.dao;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository; @Repository
public class UserDaoImpl implements UserDao {
private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
private int i = 1; public UserDaoImpl() {
System.out.println("-----call UserDaoImpl 无参构造");
} @Override
public void saveUser() {
log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i++));
} }

service是单例:

package cn.qlq.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import cn.qlq.dao.UserDao; @Service
public class UserServiceImpl implements UserService { @Autowired
private UserDao userDao; public UserServiceImpl() {
System.out.println("----- call UserServiceImpl 无参构造方法");
} @Override
public void saveUser() {
userDao.saveUser();
} }

Action还是上面代码。

测试代码:(模拟开启300个线程去访问Action)

public class MyThread implements Runnable {

    @Override
public void run() {
HttpUtils.doGet("http://localhost/struts/saveUser.do");
} public static void main(String[] args) {
MyThread mt = new MyThread();
for (int i = 0; i < 300; i++) {
new Thread(mt).start();
}
} }
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.StatusLine;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; public class HttpUtils { private static Logger logger = LoggerFactory.getLogger(HttpUtils.class); /**
* get请求
*
* @return
*/
public static String doGet(String url) {
try {
HttpClient client = new DefaultHttpClient();
// 发送get请求
HttpGet request = new HttpGet(url); HttpResponse response = client.execute(request); /** 请求发送成功,并得到响应 **/
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
/** 读取服务器返回过来的json字符串数据 **/
String strResult = EntityUtils.toString(response.getEntity(), "utf-8");
return strResult;
}
} catch (IOException e) {
logger.debug("get data error");
} return null;
} }

日志采用slf4j配置:

log4j.rootLogger=info,B

log4j.appender.A=org.apache.log4j.ConsoleAppender
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n log4j.appender.B=org.apache.log4j.RollingFileAppender
log4j.appender.B.File=E:\\test.log
log4j.appender.B.MaxFileSize=10MB
log4j.appender.B.MaxBackupIndex=5
log4j.appender.B.layout=org.apache.log4j.PatternLayout
log4j.appender.B.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

查看访问之后的日志:

2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-90,value:1
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-275,value:2
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-94,value:3
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-174,value:4
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-221,value:5
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-294,value:6
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-123,value:7
2018-08-30 22:12:19 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-93,value:8
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-103,value:9
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-80,value:10
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-15,value:11
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-133,value:12
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-120,value:13
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-239,value:14
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-54,value:15
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-44,value:16
2018-08-30 22:12:20 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-264,value:17
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-51,value:18
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-272,value:19
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-139,value:20
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-143,value:21
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-69,value:22
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-26,value:23
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-178,value:24
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-171,value:25
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-203,value:26
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-118,value:27
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-238,value:28
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-24,value:29
2018-08-30 22:12:21 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-163,value:30
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-3,value:31
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-135,value:32
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-297,value:33
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-234,value:34
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-169,value:35
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-70,value:36
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-76,value:37
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-288,value:38
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-95,value:39
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-47,value:40
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-98,value:41
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-60,value:42
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-79,value:43
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-67,value:44
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-102,value:45
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-292,value:46
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-145,value:47
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-20,value:48
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-236,value:49
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-246,value:50
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-115,value:51
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-162,value:52
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-148,value:53
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-228,value:54
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-78,value:55
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-42,value:56
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-189,value:57
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-37,value:58
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-167,value:59
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-63,value:60
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-53,value:61
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-198,value:62
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-140,value:63
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-213,value:64
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-84,value:65
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-242,value:66
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-61,value:67
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-83,value:68
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-210,value:69
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-104,value:70
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-225,value:71
2018-08-30 22:12:22 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-277,value:72
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-91,value:73
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-188,value:74
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-50,value:75
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-81,value:76
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-132,value:77
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-48,value:78
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-149,value:79
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-197,value:80
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-278,value:81
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-124,value:82
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-146,value:83
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-32,value:84
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-159,value:85
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-122,value:86
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-269,value:87
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-243,value:88
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-17,value:89
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-55,value:90
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-202,value:91
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-191,value:92
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-71,value:93
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-2,value:94
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-256,value:95
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-68,value:96
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-181,value:97
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-18,value:98
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-46,value:99
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-14,value:100
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-258,value:101
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-96,value:102
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-157,value:103
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-116,value:104
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-180,value:105
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-223,value:106
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-199,value:107
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-266,value:108
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-153,value:109
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-142,value:110
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-241,value:111
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-137,value:112
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-113,value:113
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-154,value:114
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-271,value:115
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-301,value:116
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-279,value:117
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-166,value:118
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-77,value:119
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-127,value:120
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-22,value:121
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-286,value:122
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-298,value:123
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-224,value:124
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-240,value:125
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-151,value:126
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-43,value:127
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-293,value:128
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-270,value:129
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-284,value:130
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-164,value:131
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-274,value:132
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-73,value:133
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-62,value:134
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-105,value:135
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-7,value:136
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-82,value:137
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-200,value:138
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-41,value:139
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-25,value:140
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-27,value:141
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-150,value:142
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-192,value:143
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-35,value:144
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-19,value:145
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-134,value:146
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-211,value:147
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-173,value:148
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-260,value:149
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-111,value:150
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-112,value:151
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-117,value:152
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-49,value:153
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-282,value:154
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-16,value:155
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-254,value:156
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-12,value:157
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-209,value:158
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-119,value:159
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-108,value:160
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-208,value:161
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-250,value:162
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-175,value:163
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-29,value:164
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-235,value:165
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-212,value:166
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-176,value:167
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-92,value:168
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-170,value:169
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-283,value:170
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-64,value:171
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-226,value:172
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-215,value:173
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-185,value:174
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-100,value:175
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-30,value:176
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-85,value:177
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-45,value:178
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-110,value:179
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-155,value:180
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-187,value:181
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-299,value:182
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-156,value:183
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-33,value:184
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-52,value:185
2018-08-30 22:12:23 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-201,value:186
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-276,value:187
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-296,value:188
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-263,value:189
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-109,value:190
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-290,value:191
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-8,value:192
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-193,value:193
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-129,value:194
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-141,value:195
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-56,value:196
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-40,value:197
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-39,value:198
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-88,value:199
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-195,value:200
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-97,value:201
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-257,value:202
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-196,value:203
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-177,value:204
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-168,value:205
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-36,value:206
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-4,value:207
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-161,value:208
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-291,value:210
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-267,value:209
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-101,value:211
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-86,value:212
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-273,value:213
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-253,value:214
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-216,value:215
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-218,value:216
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-13,value:217
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-231,value:218
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-87,value:219
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-249,value:220
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-165,value:221
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-172,value:222
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-227,value:223
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-190,value:224
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-160,value:225
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-219,value:226
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-237,value:227
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-204,value:228
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-144,value:229
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-59,value:230
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-295,value:231
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-38,value:232
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-281,value:233
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-262,value:234
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-268,value:235
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-244,value:236
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-74,value:237
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-265,value:238
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-158,value:239
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-58,value:241
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-125,value:240
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-147,value:242
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-21,value:243
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-72,value:244
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-10,value:245
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-57,value:246
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-207,value:247
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-280,value:248
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-179,value:249
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-247,value:250
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-130,value:251
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-259,value:252
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-251,value:253
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-261,value:254
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-75,value:255
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-107,value:255
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-220,value:256
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-128,value:257
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-300,value:258
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-248,value:259
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-285,value:260
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-114,value:261
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-89,value:262
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-289,value:263
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-230,value:264
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-23,value:265
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-66,value:267
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-222,value:268
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-184,value:266
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-6,value:269
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-245,value:270
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-186,value:271
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-214,value:272
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-106,value:273
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-28,value:274
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-252,value:275
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-194,value:276
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-138,value:277
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-9,value:278
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-136,value:279
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-183,value:278
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-255,value:280
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-152,value:281
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-232,value:283
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-131,value:282
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-31,value:284
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-206,value:285
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-287,value:286
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-126,value:287
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-65,value:288
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-182,value:289
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-229,value:290
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-205,value:289
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-34,value:291
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-121,value:292
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-5,value:294
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-11,value:293
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-233,value:295
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-217,value:296
2018-08-30 22:12:24 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-99,value:297

  查看日志发现普通的SSH环境在service与dao是单例的情况下,如果存在成员变量存在线程安全问题,结果不是我们预期的结果。

2.解决线程安全问题的简单办法

解决办法一:线程同步sychronized

代码修改为下面代码:

package cn.qlq.dao;

import java.util.concurrent.atomic.AtomicInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository; @Repository
public class UserDaoImpl implements UserDao {
private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
private int i = 1; public UserDaoImpl() {
System.out.println("-----call UserDaoImpl 无参构造");
} @Override
public synchronized void saveUser() {
log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i++));
} }

清空日志,重启服务进行测试,日志如下:

2018-08-30 22:22:58 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-288,value:1
...
2018-08-30 22:23:01 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-41,value:290
2018-08-30 22:23:01 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-299,value:291
2018-08-30 22:23:01 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-100,value:292
....
2018-08-30 22:23:45 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-40,value:599
2018-08-30 22:23:45 [cn.qlq.dao.UserDaoImpl]-[INFO] ------threamName:http-nio-80-exec-104,value:600

发现解决线程安全的问题。

解决办法二:使用JDK并发包的AtomicInteger代替in型

package cn.qlq.dao;

import java.util.concurrent.atomic.AtomicInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository; @Repository
public class UserDaoImpl implements UserDao {
private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
private AtomicInteger i = new AtomicInteger(1); public UserDaoImpl() {
System.out.println("-----call UserDaoImpl 无参构造");
} @Override
public void saveUser() {
log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i.incrementAndGet()));
} }

总结:

  对于SSH模式的应用,在dao层和service层也存在线程安全问题,所以在dao层和service层我们一般不会定义成员变量,以确保线程安全。但是在Action层由于是多例,一个请求一个实例,所以不会产生现场安全问题。因为操作的就不是同一个实例。

  解决线程安全的方法可以是加synchronized关键字或者使用JDK并发包下的AtomicXXX类代替原来的数据类型。

Spring中构造器、init-method、@PostConstruct、afterPropertiesSet孰先孰后,自动注入发生时间以及单例多例的区别、SSH线程安全问题的更多相关文章

  1. 疑问:Spring中构造器、init-method、@PostConstruct、afterPropertiesSet孰先孰后,自动注入发生时间

    问题:今天想写一个通用点的方法,根据传入的参数的类型(clazz对象),判断使用哪个mapper来插入mysql数据库. 下面是我的写法: public interface BizNeeqCommon ...

  2. 疑问:Spring 中构造器、init-method、@PostConstruct、afterPropertiesSet 孰先孰后,自动注入发生时间

    一.前言 spring的一大优点就是扩展性很强,比如,在spring bean 的生命周期中,给我们预留了很多参与bean 的生命周期的方法.大致梳理一下,有以下几种: 通过实现 Initializi ...

  3. Spring 中IOC(控制反转)&& 通过SET方式为属性注入值 && Spring表达式

    ### 1. Spring IoC IoC:Inversion of control:控制反转:在传统开发模式下,对象的创建过程和管理过程都是由开发者通过Java程序来实现的,操作权在开发者的Java ...

  4. Spring官网阅读(十七)Spring中的数据校验

    文章目录 Java中的数据校验 Bean Validation(JSR 380) 使用示例 Spring对Bean Validation的支持 Spring中的Validator 接口定义 UML类图 ...

  5. 原创 | 我被面试官给虐懵了,竟然是因为我不懂Spring中的@Configuration

    GitHub 3.7k Star 的Java工程师成神之路 ,不来了解一下吗? GitHub 3.7k Star 的Java工程师成神之路 ,真的不来了解一下吗? GitHub 3.7k Star 的 ...

  6. 我被面试官给虐懵了,竟然是因为我不懂Spring中的@Configuration

    现在大部分的Spring项目都采用了基于注解的配置,采用了@Configuration 替换标签的做法.一行简单的注解就可以解决很多事情.但是,其实每一个注解背后都有很多值得学习和思考的内容.这些思考 ...

  7. 谈谈Spring中的对象跟Bean,你知道Spring怎么创建对象的吗?

    本系列文章: 读源码,我们可以从第一行读起 你知道Spring是怎么解析配置类的吗? 配置类为什么要添加@Configuration注解? 推荐阅读: Spring官网阅读 | 总结篇 Spring杂 ...

  8. Spring官网阅读(十)Spring中Bean的生命周期(下)

    文章目录 生命周期概念补充 实例化 createBean流程分析 doCreateBean流程分析 第一步:factoryBeanInstanceCache什么时候不为空? 第二步:创建对象(crea ...

  9. Spring中的Autowired注解和Resource注解的区别

    1.所属jar包不同,Autowired是Spring中的Resource是JSR-250规范定义的注解

随机推荐

  1. LINUX内核分析第一周学习总结——计算机是如何工作的

    LINUX内核分析第一周学习总结——计算机是如何工作的 张忻(原创作品转载请注明出处) <Linux内核分析>MOOC课程http://mooc.study.163.com/course/ ...

  2. 实训六(Cocos2dx游戏分享到微信朋友圈----AppID的获取)

    考虑把游戏分享到微信朋友圈,前面的博文已经写到,shareSDK是一个很好的选择,但是学习了几天时间,遇到了很多问题,与其在一棵树上吊死,还不如退一步海阔天空,先暂时放一放,于是我考虑了一下既然是分享 ...

  3. Daily Scrum - 11/13

    时间:3:00pm - 3:30pm 今天小组例会主要是任烁分享他对WP源码的code review,通过分析与讨论我们了解了背单词模块的主要类(主要是词和单词本),取词方式(调用数据库接口),算法( ...

  4. Daily Scrum 10.20

    今天进行了团队第一次scrum meeting,在这次会议中,我们针对NABC模型以及开发前期的工作进行了探讨. 第一次会议 主要内容如下: 为了大家接下来几周的开发效率,需要共同商量团队的一些规则 ...

  5. 团队作业一 庆祝"十五万的总冠军"成立

    很荣幸能够撰写我们团队的第一篇博客. 我们这些同学能组成一个新的团队真的很高兴,团队中的每一个人都有自己的优点的长处.希望在工作中我们能竭尽 所能,充分发挥我们的本事,让我们大家各自发挥自己的才能.. ...

  6. Linux基础六(网络管理)

    目录 一.网络配置 1. IP 地址配置 2. 网络配置文件 3. 虚拟机网络配置参数 二.网络命令 1. 网络环境查看命令 2. 网络测试命令 三.远程会话安全协议-SSH原理 1. SSH 原理 ...

  7. Oracle VirtualBox添加虚拟机

    Oracle VirtualBox添加虚拟机 我的台式机是毁灭者,主板是华硕主板:安装的系统是win7 64bit.本来默认打算在该机器上面安装virtualBox,然后在virtualBox上面安装 ...

  8. chrome-extension & inject.js

    chrome-extension & inject.js chrome-extension://gppongmhjkpfnbhagpmjfkannfbllamg/js/inject.js in ...

  9. 【大数据】SparkStreaming学习笔记

    第1章 Spark Streaming概述 1.1 Spark Streaming是什么 Spark Streaming用于流式数据的处理.Spark Streaming支持的数据输入源很多,例如:K ...

  10. Emacs 安装配置使用教程

    Emacs 安装配置使用教程 来源 https://www.jianshu.com/u/a27b97f900f7 序|Preface 先来一篇有趣的简介:Emacs和Vim:神的编辑器和编辑器之神 - ...