Java的泛型反射

摘要: 上文档DOC,如果父类是一个参数化类型,那么Type返回的是参数类型的真实类型 记录总结,只有继承的父类为参数化类型,此时反射的 阅读全文
posted @ 2016-11-27 14:34 winters86 阅读(255) 评论(0) 推荐(0) 编辑

SpringFrameWork 上下文工具类

摘要: //Servlet上下文ServletContext application = event.getServletContext(); //Spring应用上下文ApplicationContext applicationContext = WebApplicationContextUtils.ge 阅读全文
posted @ 2016-11-21 12:03 winters86 阅读(131) 评论(0) 推荐(0) 编辑

后端开发学习笔记--事务隔离

摘要: 首先,作为一个程序员,需要思考的问题是,我们为什么需要事务 事务是多线程操作数据库下,为了解决数据一致性问题由数据库提供的一种手段,映射到多线程实际编程实践中,事务解决的问题就是多线程需要解决的数据竞争 而事务主要强调的是数据前后一致性,而不是多线程并发 从一个简单错误例子来讲, 在高并发秒杀业务的 阅读全文
posted @ 2016-11-21 06:01 winters86 阅读(164) 评论(0) 推荐(0) 编辑

Spring JPA Junit 关闭自动回滚

摘要: 因为用了JPA配合Hibernate ,采用注解默认是开启了LayzLoad也就是懒加载,所以不得不在Junit的单元测试上加上@Transactional注解 这样Spring会自动为当前线程开启Session,这样在单元测试里面懒加载才不会因为访问完Repo之后,出现session not fo 阅读全文
posted @ 2016-11-13 15:36 winters86 阅读(982) 评论(2) 推荐(2) 编辑

LazyInitializationException: could not initialize proxy no session

摘要: 这完全是框架设计者的锅,讲道理 无论是SSH SSM都太重了, Hibernate几乎把SQL完全封装了一遍,简单的一对多关系,如果开启LazyLoad 这样实体类会被代理,直到访问这个多方实体的属性的时候,才会加载 在webxml中加入 Spring针对Hibernate的非JPA实现用的是Ope 阅读全文
posted @ 2016-11-13 10:13 winters86 阅读(228) 评论(0) 推荐(0) 编辑

网易2017 洗牌

摘要: package com.net163.question; import org.junit.Test; import java.util.Stack; /** * Created by Administrator on 2016/11/11 0011. */ public class Card { private int card[] = {1, 2, 3, 4, 5, 6};... 阅读全文
posted @ 2016-11-11 14:27 winters86 阅读(118) 评论(0) 推荐(0) 编辑

网易2017 计算糖果

摘要: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ins = new Scanner(System.in); while (ins.hasNextInt()) {//注意while处理多个case ... 阅读全文
posted @ 2016-11-11 12:14 winters86 阅读(232) 评论(0) 推荐(0) 编辑

网易2017 买苹果

摘要: 小易去附近的商店买苹果,奸诈的商贩使用了捆绑交易,只提供6个每袋和8个每袋的包装(包装不可拆分)。 可是小易现在只想购买恰好n个苹果,小易想购买尽量少的袋数方便携带。如果不能购买恰好n个苹果,小易将不会购买。 阅读全文
posted @ 2016-11-11 11:43 winters86 阅读(244) 评论(0) 推荐(0) 编辑

网易2017 最大奇约数

摘要: 没啥难度直接贴代码 阅读全文
posted @ 2016-11-11 11:20 winters86 阅读(355) 评论(0) 推荐(0) 编辑

网易2017 数字翻转

摘要: package com.net163.question; import org.junit.Test; /** * Created by Administrator on 2016/11/11 0011. */ public class ReverseNumber { private int x = 123 , y=100; public int reverse(int ... 阅读全文
posted @ 2016-11-11 11:10 winters86 阅读(209) 评论(0) 推荐(0) 编辑