
java
jimmy_游戏人生
热爱技术,为专研技术可以废寝忘食。
展开
-
for each 接口的实现
java1.5提供了for each的循环方式,实现iterable接口就能让自己的类也能这么来循环,写一个例子。 MainTestJava代码 package org.hx.itr; import java.util.Iterator; import java.util.UUID; public class MainTest {原创 2013-11-16 23:19:24 · 891 阅读 · 0 评论 -
eclipse 代码自动补全功能增加
http://zhangxiang390.javaeye.com/blog/258392原创 2013-11-17 18:24:00 · 631 阅读 · 0 评论 -
hibernate一对一主键关联_单向
说明:get and set 忽略public class User { private int id; private String username; private IdCard idCard;}public class IdCard { private int id; private String cardNO;} class name="原创 2013-11-17 18:32:35 · 671 阅读 · 0 评论 -
为什么要使用log4j isDebugEnabled
一般的调试信息会拼接大量的字符串,所以虽然设置的调试级别很高,调试信息不会打印,但是拼接字符串的工作还是执行了,这些工作降低了系统的性能。所以一般用log.isDebugEnabled()来判断一下,提高系统性能:if (log.isDebugEnabled()) {log.debug(" From: " + req.getFrom().toString() +" To: " + re原创 2013-11-17 18:13:23 · 1247 阅读 · 0 评论 -
java集合类get set 的写法
对于集合类,如List ,在用get 和set 时,应该如下:private List args = new ArrayList();public List getArgs() {return args;}public void addAgr(String arg){}原创 2013-11-17 18:14:56 · 2276 阅读 · 0 评论 -
并发包中的BlockingQueue这个类的介绍及使用
import java.util.concurrent.ArrayBlockingQueue;import java.util.concurrent.BlockingQueue;import java.util.concurrent.ExecutorService;import java.util.concurrent.Executors; /** 本例介绍一个特殊原创 2013-11-17 18:17:10 · 955 阅读 · 0 评论 -
hibernate一对一主键关联映射双向
public class IdCard { private int id; private String cardNO; private User user;} public class User { private int id; private String username; private IdCard idCard;}原创 2013-11-17 18:31:58 · 564 阅读 · 0 评论 -
关于了类继承父类后,私有数据的问题。
父类的私有数据子类也会继承,但是子类无法操作这个私有的数据。原创 2013-11-17 18:19:08 · 878 阅读 · 0 评论 -
hibernate多对一的映射的配置
public class Group { private int id; private String groupName;} public class User { private int id; private String username; private String userpwd; private Group group; }原创 2013-11-17 18:25:54 · 667 阅读 · 0 评论 -
JPA增删改查
查找对象 1) 用find()方法查找对象Java代码 public void getPerson(){ EntityManagerFactory factory = Persistence.createEntityManagerFactory("jpa"); EntityManager em = factory.cr原创 2013-11-19 14:49:43 · 1057 阅读 · 0 评论 -
代码简洁之道
1. the clean code is that it can pass the test2.no reduplicate code3. the less class or function name:1.the class name should be n. ,not be vi or vt. Address ,Processor ..2. the fu原创 2013-11-19 14:47:02 · 710 阅读 · 0 评论 -
nekohtml中解析中出现中文乱码问题
后来,确认问题应该出现在nekohtml(HtmlParser默认使用的html文档解析包)身上,于是下载nekohtml查看源码,发现默认情况下,如果nekohtml在页面中找到charset的设置,他将使用页面中指定的编码集,所以大量的页面都用页面中指定的GB2312进行解析,这样如果页面中存在GB2312没有包含的字符时就会出现乱码,在HtmlScanner中有一个特征(Feature)原创 2014-05-05 17:37:35 · 1382 阅读 · 0 评论 -
maven export dependency 导出依赖包的命令,jar 安装到本地
mvn dependency:copy-dependencies -D dependency-lib/原创 2013-11-19 14:51:04 · 2936 阅读 · 0 评论 -
关于spring 的那些事
一. spring 相关的坑 1. context:property-placeholderlocation="classpath:db.properties"/> 只能配置一个,如何配置多个,后面的properties会被spring 忽略。正确的做法是: context:property-placeholder location="classpath:*.pr原创 2016-09-28 12:45:08 · 341 阅读 · 0 评论 -
聊聊java那些事(一)--并发
在编程的世界里,说的最多的也是最具体有技术含量的就是并发编程了。有的同学一说到并发,就想的多线程,多进程。还有没有其它的并发编程的方案呢,答案是肯定的。有一本书叫《seven concurrency models in seven days》,里面就讲了7种并发的编程模型,今天的学习,就带领大家领略7种并发编程的技术及笔者的一些思考。在开始说并发之前,让我们先区分一下 concurrency原创 2016-09-30 19:14:45 · 1407 阅读 · 0 评论 -
深入理解java 版本兼容问题
我们在做dubbo接口开发是,要考虑jdk版本兼容的问题。如果是高版本的jre运行低版本jdk compile 的jar,根据java的向下兼容性,这个没有问题。但如果是低版本jre运行高版本的jdk compile的jar,会怎么样呢?问题的背景最近在做项目时,由于要用到elastichsearch 做开发,elastichsearch 的jdk版本是java7,而公司要求的java版本一般来说是原创 2017-01-11 16:33:59 · 19082 阅读 · 0 评论 -
jstl核心库的学习
1.el表达式是可以单独使用的。在web页面引入jstl库http://java.sun.com/jsp/jstl/core%> 把变量赋值给temp把变量去除。 v1 是否为空是不能单独用的。 v1 小于v2v1 大于 when可以有多个,otherwise 只能有一个。 迭代标签原创 2013-11-17 18:21:20 · 759 阅读 · 0 评论 -
java日期类 calendar的使用
Calendar c = Calendar.getInstance(); SimpleDateFormat s = new SimpleDateFormat("yyyy-MMdd"); Date d = s.parse("2011-0418"); c.setTime(d);原创 2013-11-17 18:20:35 · 717 阅读 · 0 评论 -
hibernate 一对一外键关联映射_单向
public class User { private int id; private String username; private IdCard idCard; } public class IdCard { private int id; private String cardNO;}原创 2013-11-17 18:31:06 · 601 阅读 · 0 评论 -
start up along with tomcat
commonMonitorClient com.yoyosys.cwconsoleex.client.CommonMonitorClient 2 start up along with web container .such as tomcat,weblogic.public class CommonMonitorClient extends HttpServ原创 2013-11-16 23:23:52 · 650 阅读 · 0 评论 -
about cache
public static final Cache = new Cache();the Cache must be static end final.原创 2013-11-16 23:24:55 · 983 阅读 · 0 评论 -
自动重连
private boolean reconnection() throws Exception { int index = 0; while (index index++; LOG.error("try reconnection bitsflow agent " +原创 2013-11-16 23:25:41 · 803 阅读 · 0 评论 -
the diff of configuration,configured,configurable
configuration means a file for the system.configurable is a interface.configured implements configurable . it means the system is configurable. the construct ispublic class configur原创 2013-11-16 23:26:54 · 623 阅读 · 0 评论 -
观察者模式的使用
public class Observed { //被观察者private PropertyChangeSupport listenr = new PropertyChangeSupport(this); //this ---> sourcebeanpublic void addPropertyChangedListener(PropertyChangeListener listene原创 2013-11-16 23:27:44 · 611 阅读 · 0 评论 -
Comparator 接口的使用
import java.util.Comparator;public class KeyValueComparator implements Comparator { /** desc */ public int compare(KeyValue o1, KeyValue o2) { if (o1.getValue() > o2.getValue()) {原创 2013-11-16 23:18:21 · 690 阅读 · 0 评论 -
how to generate the javadoc,java sources
javadoc -d api org/eclipse/swt/SWT.java //处理单个源文件javadoc -d api org.eclipse.swt //处理单个包javadoc -d api org.eclipse.swt org.eclipse.swt.widgets//处理多个包,如果处理的包较少,可以采用直接输入的方法javadoc -private -d原创 2013-11-16 23:20:25 · 819 阅读 · 0 评论 -
java 读取系统环境变量
System.getEnv("BITSFLOW_HOME");原创 2013-11-16 23:26:07 · 706 阅读 · 0 评论 -
the different between daemon thread and the user thread
the user thread can change to daemon thread. you can use the method setDaemon(ture) to change it.if the user thread exit,eg main Thread. the JVM will tell the daemon thread to die and exit JVM原创 2013-11-16 23:22:50 · 938 阅读 · 0 评论 -
class loader 的路径问题
//URL url = this.getClass().getResource("config.ini");config.ini 文件应该和this 所对应的class在同一个包中。this.getClass().getClassLoader.getResource("config.ini");这个config.ini应该放在 src的根路径下。原创 2013-11-17 18:15:43 · 833 阅读 · 0 评论 -
在做code reivew时的心得
接口 注释return int searhRolesCount(String name)ListgetLogType 为list 的话,方法应该为 getLogTypes单词拼写要正确释放资源原则:哪里创建,哪里释放通过finally 释放资源,system.exit() 不执行finally不可变类的定义:这个类的对象一但创建,对象中的数据成量是不允许修改的。原创 2013-11-17 18:18:28 · 859 阅读 · 0 评论 -
struts2采用convention-plugin实现零配置
参考iteye上的文章http://javeye.javaeye.com/blog/358744原创 2013-11-17 18:23:12 · 715 阅读 · 0 评论 -
工厂设计模式的简单使用
1.简单工厂//定义三种产品,这三种产品都是交通工具,它们都实现Moveable这个接口public interface Moveable { void run();}class Car implements Moveable{}class Plane implements Moveable{}class Broom implements Moveable原创 2013-11-17 18:24:43 · 645 阅读 · 0 评论 -
OO的思想
用面向对象的思想对这句话进行建模:老张开车到东北 public class driver{private String name;public void drive(Car c,Address a){c.go(a);}}class Car{public void go(){ System.out.println("东北");}原创 2013-11-17 18:25:06 · 755 阅读 · 0 评论 -
hibernate 一对一外键关联映射_双向
public class User { private int id; private String username; private IdCard idCard;} public class IdCard { private int id; private String cardNO; private User user;}原创 2013-11-17 18:26:44 · 649 阅读 · 0 评论 -
如何使用commond compile java
#!/bin/bashlibs=$(find ./lib -iname "*.jar")classpath='./'for lib in $libs do classpath=$classpath:$lib donesources=$(find -iname "*.java")echo $classpathecho $sources原创 2017-01-11 17:17:23 · 790 阅读 · 0 评论