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

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

  1. 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

  1. package zd.dms.job.ebuy;
  2.  
  3. import javax.annotation.PostConstruct;
  4. import javax.annotation.PreDestroy;
  5.  
  6. import org.springframework.beans.factory.DisposableBean;
  7. import org.springframework.beans.factory.InitializingBean;
  8. import org.springframework.beans.factory.annotation.Autowired;
  9.  
  10. import zd.dms.dao.ebuy.GroupDao;
  11.  
  12. public class Person implements InitializingBean,DisposableBean{
  13. private String name;
  14.  
  15. @Autowired
  16. private GroupDao groupDao;
  17.  
  18. public Person() {
  19. System.out.println("---------------实例化一个Person对象----------");
  20. System.out.println("---------------groupDao is -----------"+groupDao);
  21. }
  22.  
  23. public void init() {
  24. System.out.println("------------这是xml的init方法----------....");
  25. System.out.println("---------------groupDao is -----------"+groupDao);
  26. }
  27.  
  28. public void destory() {
  29. System.out.println("---------------这是xml的destroy方法....");
  30. System.out.println("---------------groupDao is -----------"+groupDao);
  31. }
  32.  
  33. @PostConstruct
  34. public void init2() {
  35. System.out.println("------------这是@PostConstruct的init方法----------....");
  36. System.out.println("---------------groupDao is -----------"+groupDao);
  37. }
  38.  
  39. @PreDestroy
  40. public void destory2() {
  41. System.out.println("---------------这是@PreDestroy的destroy方法....");
  42. System.out.println("---------------groupDao is -----------"+groupDao);
  43. }
  44.  
  45. @Override
  46. public void destroy() throws Exception {
  47. System.out.println("-----------这是DisposableBean的destroy方法....");
  48. System.out.println("---------------groupDao is -----------"+groupDao);
  49. }
  50.  
  51. @Override
  52. public void afterPropertiesSet() throws Exception {
  53. System.out.println("-------这是InitializingBean的afterPropertiesSet方法....");
  54. System.out.println("---------------groupDao is -----------"+groupDao);
  55. }
  56. }

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

配置:

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

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

  1. @Namespace("/qlqTest")
  2. @SuppressWarnings("all")
  3. public class TestAction extends DMSActionSupport {
  4.  
  5. @Autowired
  6. private Person person;
  7. /**
  8. *
  9. */
  10. private static final long serialVersionUID = -8934360924125349297L;
  11.  
  12. @Autowired
  13. private GroupAndUserService groupAndUserService;
  14.  
  15. private Map resultMap;
  16.  
  17. @Action("test")
  18. public String testAction() {
  19. person.getClass();
  20. return "js";
  21. }
  22. }

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

  1. - ---------------实例化一个Person对象----------
  2. ---------------groupDao is -----------null
  3. ------------这是@PostConstructinit方法----------....
  4. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
  5. -------这是InitializingBeanafterPropertiesSet方法....
  6. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
  7. ------------这是xmlinit方法----------....
  8. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3

证明对象创建的顺序:

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

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

销毁的时候的结果:

  1. ---------------这是@PreDestroydestroy方法....
  2. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
  3. -----------这是DisposableBeandestroy方法....
  4. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3
  5. ---------------这是xmldestroy方法....
  6. ---------------groupDao is -----------zd.dms.dao.ebuy.GroupDaoImpl@435598e3

所以销毁顺序为:

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

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

配置:

  1. <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:

  1. package cn.qlq.action;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import org.apache.struts2.convention.annotation.Action;
  7. import org.apache.struts2.convention.annotation.Namespace;
  8. import org.apache.struts2.convention.annotation.ParentPackage;
  9. import org.apache.struts2.convention.annotation.Result;
  10. import org.apache.struts2.convention.annotation.Results;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Controller;
  13.  
  14. import com.opensymphony.xwork2.ActionSupport;
  15.  
  16. import cn.qlq.service.UserService;
  17.  
  18. @Namespace("/")
  19. @ParentPackage("default")
  20. @Controller("firstAction")
  21. @Results({ @Result(name = "redirect", location = "/index2.jsp", type = "redirect"),
  22. @Result(name = "forward", location = "/index.jsp"),
  23. @Result(name = "json", type = "json", params = { "root", "responseMap" }) })
  24. public class UserAction extends ActionSupport {
  25.  
  26. private Map<String, Object> responseMap = new HashMap<String, Object>();
  27.  
  28. @Autowired
  29. private UserService userService;
  30.  
  31. public UserAction() {
  32. System.out.println("-----call UserAction 无参构造方法");
  33. }
  34.  
  35. @Action("saveUser")
  36. public String saveUser() {
  37. userService.saveUser();
  38. return "json";
  39. }
  40.  
  41. public Map<String, Object> getResponseMap() {
  42. return responseMap;
  43. }
  44.  
  45. public void setResponseMap(Map<String, Object> responseMap) {
  46. this.responseMap = responseMap;
  47. }
  48.  
  49. }

Service:

  1. package cn.qlq.service;
  2.  
  3. public interface UserService {
  4. public void saveUser();
  5. }
  1. package cn.qlq.service;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5.  
  6. import cn.qlq.dao.UserDao;
  7.  
  8. @Service
  9. public class UserServiceImpl implements UserService {
  10.  
  11. @Autowired
  12. private UserDao userDao;
  13.  
  14. public UserServiceImpl() {
  15. System.out.println("----- call UserServiceImpl 无参构造方法");
  16. }
  17.  
  18. @Override
  19. public void saveUser() {
  20. userDao.saveUser();
  21. }
  22.  
  23. }

Dao:

  1. package cn.qlq.dao;
  2.  
  3. public interface UserDao {
  4.  
  5. public void saveUser();
  6. }
  1. package cn.qlq.dao;
  2.  
  3. import org.springframework.stereotype.Repository;
  4.  
  5. @Repository
  6. public class UserDaoImpl implements UserDao {
  7.  
  8. public UserDaoImpl() {
  9. System.out.println("-----call UserDaoImpl 无参构造");
  10. }
  11.  
  12. @Override
  13. public void saveUser() {
  14. try {
  15. Thread.sleep(4 * 1000);
  16. } catch (InterruptedException e) {
  17. e.printStackTrace();
  18. }
  19. System.out.println("----user dao (save user)---");
  20. }
  21.  
  22. }

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

多次访问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的代码:

  1. package cn.qlq.dao;
  2.  
  3. import org.slf4j.Logger;
  4. import org.slf4j.LoggerFactory;
  5. import org.springframework.stereotype.Repository;
  6.  
  7. @Repository
  8. public class UserDaoImpl implements UserDao {
  9. private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
  10. private int i = 1;
  11.  
  12. public UserDaoImpl() {
  13. System.out.println("-----call UserDaoImpl 无参构造");
  14. }
  15.  
  16. @Override
  17. public void saveUser() {
  18. log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i++));
  19. }
  20.  
  21. }

service是单例:

  1. package cn.qlq.service;
  2.  
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.stereotype.Service;
  5.  
  6. import cn.qlq.dao.UserDao;
  7.  
  8. @Service
  9. public class UserServiceImpl implements UserService {
  10.  
  11. @Autowired
  12. private UserDao userDao;
  13.  
  14. public UserServiceImpl() {
  15. System.out.println("----- call UserServiceImpl 无参构造方法");
  16. }
  17.  
  18. @Override
  19. public void saveUser() {
  20. userDao.saveUser();
  21. }
  22.  
  23. }

Action还是上面代码。

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

  1. public class MyThread implements Runnable {
  2.  
  3. @Override
  4. public void run() {
  5. HttpUtils.doGet("http://localhost/struts/saveUser.do");
  6. }
  7.  
  8. public static void main(String[] args) {
  9. MyThread mt = new MyThread();
  10. for (int i = 0; i < 300; i++) {
  11. new Thread(mt).start();
  12. }
  13. }
  14.  
  15. }
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.net.URI;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.Iterator;
  8. import java.util.List;
  9. import java.util.Map;
  10.  
  11. import org.apache.http.HttpEntity;
  12. import org.apache.http.HttpResponse;
  13. import org.apache.http.HttpStatus;
  14. import org.apache.http.NameValuePair;
  15. import org.apache.http.StatusLine;
  16. import org.apache.http.client.HttpClient;
  17. import org.apache.http.client.entity.UrlEncodedFormEntity;
  18. import org.apache.http.client.methods.CloseableHttpResponse;
  19. import org.apache.http.client.methods.HttpGet;
  20. import org.apache.http.client.methods.HttpPost;
  21. import org.apache.http.entity.StringEntity;
  22. import org.apache.http.impl.client.CloseableHttpClient;
  23. import org.apache.http.impl.client.DefaultHttpClient;
  24. import org.apache.http.impl.client.HttpClients;
  25. import org.apache.http.message.BasicNameValuePair;
  26. import org.apache.http.protocol.HTTP;
  27. import org.apache.http.util.EntityUtils;
  28. import org.slf4j.Logger;
  29. import org.slf4j.LoggerFactory;
  30.  
  31. public class HttpUtils {
  32.  
  33. private static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
  34.  
  35. /**
  36. * get请求
  37. *
  38. * @return
  39. */
  40. public static String doGet(String url) {
  41. try {
  42. HttpClient client = new DefaultHttpClient();
  43. // 发送get请求
  44. HttpGet request = new HttpGet(url);
  45.  
  46. HttpResponse response = client.execute(request);
  47.  
  48. /** 请求发送成功,并得到响应 **/
  49. if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
  50. /** 读取服务器返回过来的json字符串数据 **/
  51. String strResult = EntityUtils.toString(response.getEntity(), "utf-8");
  52. return strResult;
  53. }
  54. } catch (IOException e) {
  55. logger.debug("get data error");
  56. }
  57.  
  58. return null;
  59. }
  60.  
  61. }

日志采用slf4j配置:

  1. log4j.rootLogger=info,B
  2.  
  3. log4j.appender.A=org.apache.log4j.ConsoleAppender
  4. log4j.appender.A.layout=org.apache.log4j.PatternLayout
  5. log4j.appender.A.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n
  6.  
  7. log4j.appender.B=org.apache.log4j.RollingFileAppender
  8. log4j.appender.B.File=E:\\test.log
  9. log4j.appender.B.MaxFileSize=10MB
  10. log4j.appender.B.MaxBackupIndex=5
  11. log4j.appender.B.layout=org.apache.log4j.PatternLayout
  12. log4j.appender.B.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} [%c]-[%p] %m%n

查看访问之后的日志:

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

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

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

解决办法一:线程同步sychronized

代码修改为下面代码:

  1. package cn.qlq.dao;
  2.  
  3. import java.util.concurrent.atomic.AtomicInteger;
  4.  
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.stereotype.Repository;
  8.  
  9. @Repository
  10. public class UserDaoImpl implements UserDao {
  11. private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
  12. private int i = 1;
  13.  
  14. public UserDaoImpl() {
  15. System.out.println("-----call UserDaoImpl 无参构造");
  16. }
  17.  
  18. @Override
  19. public synchronized void saveUser() {
  20. log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i++));
  21. }
  22.  
  23. }

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

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

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

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

  1. package cn.qlq.dao;
  2.  
  3. import java.util.concurrent.atomic.AtomicInteger;
  4.  
  5. import org.slf4j.Logger;
  6. import org.slf4j.LoggerFactory;
  7. import org.springframework.stereotype.Repository;
  8.  
  9. @Repository
  10. public class UserDaoImpl implements UserDao {
  11. private static Logger log = LoggerFactory.getLogger(UserDaoImpl.class);
  12. private AtomicInteger i = new AtomicInteger(1);
  13.  
  14. public UserDaoImpl() {
  15. System.out.println("-----call UserDaoImpl 无参构造");
  16. }
  17.  
  18. @Override
  19. public void saveUser() {
  20. log.info("------threamName:{},value:{}", Thread.currentThread().getName(), String.valueOf(i.incrementAndGet()));
  21. }
  22.  
  23. }

总结:

  对于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. 【Beta阶段】第五次Scrum Meeting!

    每日任务内容: 本次会议为第五次Scrum Meeting会议~ 由于本次会议项目经理召开时间依旧较晚,在公寓7层召开,女生参与了线上会议. 队员 昨日完成任务 明日要完成任务 刘乾 #167(未完成 ...

  2. Linux内核读书笔记第二周

    什么是系统调用 简单来说,系统调用就是用户程序和硬件设备之间的桥梁.用户程序在需要的时候,通过系统调用来使用硬件设备. 系统调用的存在,有以下重要的意义: 1)用户程序通过系统调用来使用硬件,而不用关 ...

  3. C语言入门:05.scanf函数

    一.变量的内存分析 1.字节和地址 为了更好地理解变量在内存中的存储细节,先来认识一下内存中的“字节”和“地址”. (1)内存以“字节为单位”

  4. 查看django版本的方法

    在cmd输入: python -m django --version django-admin --version

  5. [转帖] 外部访问k8s 里面pod的方式方法

    https://jimmysong.io/posts/accessing-kubernetes-pods-from-outside-of-the-cluster/ 从外部访问Kubernetes中的P ...

  6. Java之资源文件读取

    ClassLoaderWrapper.java package org.utils.resource; import java.io.InputStream; import java.net.URL; ...

  7. [代码]--SQLServer数据库的一些全局变量

    select APP_NAME ( ) as w --当前会话的应用程序 select @@IDENTITY   --返回最后插入的标识值 select USER_NAME()    --返回用户数据 ...

  8. HGOI 20181103 题解

    problem:把一个可重集分成两个互异的不为空集合,两个集合里面的数相乘的gcd为1(将集合中所有元素的质因数没有交集) solution:显然本题并不是那么容易啊!考场上想了好久.. 其实转化为上 ...

  9. Problem C Dist 解题报告

    Problem C Dist Description 有一个\(n\)个点带边权的连通无向图,边集用\(k\)个集合\(s_1,s_2,\dots,s_k\)和\(k\)个整数\(w_1,w_2,\d ...

  10. 前端学习 -- Html&Css -- 相对定位 绝对定位 固定定位

    相对定位 - 定位指的就是将指定的元素摆放到页面的任意位置,通过定位可以任意的摆放元素. - 通过position属性来设置元素的定位. -可选值: static:默认值,元素没有开启定位: rela ...