ITeye博客

wgbaoweii的博客

wgbaoweii · 共 43 篇文章

docker-java

docker-java

2018-07-25T11:05:01Z · JAVA技巧 · 评论(0)

反射属性值

Field[] fields = bean.getClass().getDeclaredFields(); try { for (int i = 0; i < fields.length; i++) { Field f = fields[i]; // 设置些属性是可以访问的 f.setAccessible(true); logger.info(f.getName() + " - " + f.get(bean)); } } catch (Exception e) { e.printStackTrace(); }

2016-07-25T18:45:07Z · JAVA技巧 · 评论(0)

Hibernate表集成

1、父类: @Entity @Table(name = "tab_product") @Inheritance(strategy = InheritanceType.JOINED) 2、子类 @Entity @Table(name = "tab_cpa_product") @PrimaryKeyJoinColumn(name = "cpaProductId")

2016-07-25T18:42:57Z · JAVA技巧 · 评论(0)

Request头信息

System.out.println("+++++++++++++++++++++++++++++++++++++++++"); String head = request.getHeader("Accept-Encoding"); // 有些浏览器不支持压缩数据 if (head.contains("gzip")) { // 输出压缩数据 } else { // 输出不压缩数据 } // 获取指定名称的头的所有值 Enumeration e = request.getHeaders("Accept-Encoding"); while (e.hasMoreElements()) { Stri…

2016-07-25T18:42:51Z · JAVA技巧 · 评论(0)

Timestamp转Date

Timestamp ts = new Timestamp(System.currentTimeMillis()); Date date = new Date(); try { date = ts; ystem.out.println(date); } catch (Exception e) { e.printStackTrace(); }

2016-07-25T18:42:38Z · JAVA技巧 · 评论(0)

Date相减

/** * @param 要转换的毫秒数 * @return 该毫秒数转换为 * days * hours * minutes * seconds 后的格式 * @author fy.zhang */ public static String formatDuring(long mss) { long days = mss / (1000 * 60 * 60 * 24); long hours = (mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60); long minutes = (mss % (1000 * 60 * 60)) / (1000 …

2016-07-25T18:42:30Z · JAVA技巧 · 评论(0)

Spring初始化数据

<bean id="initializeService" class="com.demo.impl.InitializeServiceImpl" lazy-init="false" init-method="initialize"> <property name="dataAccessor" ref="dataAccessor"/> </bean>

2016-03-31T14:47:13Z · JAVA技巧 · 评论(0)

Spring-Junit集成

@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = {"classpath:application-context.xml"}) public abstract class SpringTestSupport { }

2016-03-31T14:47:07Z · JAVA技巧 · 评论(0)

获取枚举值

public static Role fromName(String name) { for (Role role : Role.values()) { if (StringUtils.equals(role.name(), name)) { return role; } } return null; }

2016-03-31T14:47:00Z · JAVA技巧 · 评论(0)

Hibernate配置枚举

<property name="bargainStatus"> <type name="org.hibernate.type.EnumType"> <param name="enumClass">com.demo.model.Bargain$Status</param> </type> </property>

2016-03-31T14:46:54Z · JAVA技巧 · 评论(0)

获取客户端IP

public String getClientIP(HttpServletRequest httpservletrequest) { if (httpservletrequest == null) return null; String s = httpservletrequest.getHeader("X-Forwarded-For"); if (s == null || s.length() == 0 || "unknown".equalsIgnoreCase(s)) s = httpservletrequest.getHeader("Proxy-Client-IP"); if (s =…

2016-03-31T14:45:22Z · JAVA技巧 · 评论(0)

重置Apache

1、下载链接: http://httpd.apache.org/download.cgi sudo ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --host=amd64 make & make install cp /usr/local/apache2/conf/httpd.conf /etc/apache2/httpd.conf sudo apachectl restart 2、安装apr,apr-util 1 cd /usr/lo…

2016-03-30T16:26:16Z · MAC · 评论(0)

MyBatis表关联

查询主表: <resultMap type="com.demo.bean.WXGameRankingBean" id="weiboJoinAccountResultMap"> <id property="id" column="id" /> <result property="score" column="score" /> <result property="openid" column="openid" /> <result property="createTime" column="create_time" /> <result property="gameid" column="ga…

2016-03-29T18:17:46Z · JAVA技巧 · 评论(0)

本周日期

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); int weekday = c.get(7) - 1; c.add(5, -weekday); System.out.println("JAVA-API,本周开始时间:" + sdf.format(c.getTime())); c.add(5, 6); System.out.print…

2016-03-29T18:17:29Z · JAVA技巧 · 评论(0)

Map循环

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> Map<String, String> map = ... for (String key : map.keySet()) { System.out.println(key + map.get(key)); } for (Map.Entry<String, String> entry : map.entrySet()) { System.out.println(entry.getKey() + entry.getValue()); }

2016-03-29T18:16:31Z · JAVA技巧 · 评论(0)