Skip to content

Instantly share code, notes, and snippets.

@jwlyn
jwlyn / read-resource-file-as-string.java
Created July 21, 2015 09:26
读取一个resources下的properties文件,一行一行地读取。 不需要读取成为Properteis
private static List<Request> loadRequest() throws IOException {
InputStream inputStream = Main.class.getClassLoader().getResourceAsStream("seeds.properties");
final Reader in = new InputStreamReader(inputStream, "UTF-8");
LineNumberReader rd = new LineNumberReader(in);
String line = null;
while((line=rd.readLine())!=null){
}
}
@jwlyn
jwlyn / spring-junit.java
Created June 23, 2015 09:03
spring 测试
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.junit.Assert.assertNotNull;
@RunWith(SpringJUnit4ClassRunner.class)
@jwlyn
jwlyn / spring单机触发任务执行
Created June 3, 2015 03:22
在单机上定时执行任务
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
<task:annotation-driven /> <!-- 定时器开关-->
<bean id="myTask" class="com.pkg.SomeTask">
<property name="xx" value="xx"/>
</bean>
<task:scheduled-tasks>
<task:scheduled ref="myTask" method="jobMethod" cron="* */25 * * * ?"/>
</task:scheduled-tasks>
@jwlyn
jwlyn / maven groovy
Created May 28, 2015 11:30
maven管理groovy工程
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groovy.test</groupId>
<artifactId>mytest</artifactId>
<version>1.0-SNAPSHOT</version>
@jwlyn
jwlyn / Main.java
Created April 7, 2015 12:04
JMX 动态推送参数
package test;
import thread.SystemConfig;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import java.lang.management.ManagementFactory;
/**
* Created by cxu on 2015/4/7.
@jwlyn
jwlyn / diamond.sql
Last active August 29, 2015 14:01
淘宝diamond的sql脚本
create database if not exists `diamond`;
grant all on diamond.* to zh@'%' identified by 'abc';
use `diamond`;
create table config_info (
`id` bigint(64) unsigned NOT NULL auto_increment,
`data_id` varchar(255) NOT NULL DEFAULT '',
`group_id` varchar(128) NOT NULL DEFAULT '',
@jwlyn
jwlyn / Main.java
Created May 10, 2014 04:43
最简单的jetty http server
import org.eclipse.jetty.server.Server;
/** The simplest possible Jetty server.
 */
public class Main
{
public static void main(String[] args) throws Exception
{
Server server = new Server(8080);
server.start();
@jwlyn
jwlyn / gist:edca208e1f6faed24d66
Created May 5, 2014 02:32
防止jetty将文件解压到/tmp下,这样会被tempd进程隔几天删除
<Set name="tempDirectory"><Property name="jetty.home" default="." />/work</Set>