Skip to content

Instantly share code, notes, and snippets.

View bohrqiu's full-sized avatar

bohr bohrqiu

View GitHub Profile
@bohrqiu
bohrqiu / gist:817669f38261104c31d8
Created August 21, 2014 06:55
tomcat-maven-plugin config ssl
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
@bohrqiu
bohrqiu / monitor_create_thread
Last active August 29, 2015 14:05
btrace script monitor create new thread
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class TracingScript {
public static int count = 0;
@OnMethod(clazz = "java.lang.Thread", method = "start")
public static void onNewThread() {
@bohrqiu
bohrqiu / gist:1f32d3575e89ec09e8d5
Last active August 29, 2015 14:05
maven remote debug
MAVEN_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8765'

transport

这里通常使用套接字传输。但是在 Windows 平台上也可以使用共享内存传输。

server

@bohrqiu
bohrqiu / gist:40fdc0734f171eb5486e
Created September 23, 2014 16:50
查看java进程启动线程数
for pid in `ps -ef |grep java| grep -v 'grep'| awk '{print $2}'`
do
cat /proc/$pid/status |grep Threads | awk '{print $2}'
done
@bohrqiu
bohrqiu / .xml
Created August 18, 2015 10:18
build source to binary jar
<build>
<resources>
<resource>
<directory>src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@bohrqiu
bohrqiu / DataSourceHealthIndicator.java
Created November 5, 2015 07:47
DataSourceHealthIndicator with timeout
/*
* Copyright 2012-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@bohrqiu
bohrqiu / gist:5503811
Created May 2, 2013 17:24
druid slf4j日志集成
diff --git a/src/main/java/com/alibaba/druid/support/logging/LogFactory.java b/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
index dbdc21a..fe6f467 100644
--- a/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
+++ b/src/main/java/com/alibaba/druid/support/logging/LogFactory.java
@@ -23,9 +23,7 @@
private static Constructor logConstructor;
static {
- // TODO add slf4j logging
-
@bohrqiu
bohrqiu / dump.sh
Last active December 22, 2015 19:19
java进程关闭时收集dump
JAVA_HOME=/usr/lib/jvm/java-7-sun
OUTPUT_HOME=/var/log/webapps/cs/
DEPLOY_HOME=/usr/local/apache-tomcat-7.0.26-cs
HOST_NAME=`hostname`
DUMP_PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_HOME" |awk '{print $2}'`
if [ -z "$DUMP_PIDS" ]; then
echo "The server $HOST_NAME is not started!"
exit 1;
fi
@bohrqiu
bohrqiu / jetty
Last active December 31, 2015 19:49
java web项目测试时启动jetty
1.在项目父pom中添加build插件:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.0.v20131115</version>
<configuration>
<reload>automatic</reload>
</configuration>
</plugin>
@bohrqiu
bohrqiu / maven-package-verson
Last active December 31, 2015 19:58
maven打包时,自动生成静态资源版本号
1.在web项目pom里面添加build插件
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<includes>