>(){});
28 | PrintUtils.print("写入文件读取JSON数据", persons.size() == personList.size());
29 | PrintUtils.print("写入文件读取JSON数据", personList);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/json-example/jackson-example/src/main/java/io/github/biezhi/json/jackson/IgnoreUnknownExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.json.jackson;
2 |
3 | import com.fasterxml.jackson.databind.ObjectMapper;
4 | import io.github.biezhi.json.jackson.model.Employee4;
5 | import io.github.biezhi.utils.PrintUtils;
6 |
7 | import java.io.IOException;
8 |
9 | /**
10 | * Jackson 注解忽略未知字段示例
11 | *
12 | * @author biezhi
13 | * @date 2018/1/15
14 | */
15 | public class IgnoreUnknownExample {
16 |
17 | private static final ObjectMapper mapper = new ObjectMapper();
18 |
19 | public static void main(String[] args) throws IOException {
20 | String s = "{\"name\":\"biezhi\",\"phone\":\"111-111-1111\"}";
21 | System.out.println("JSON input: " + s);
22 | Employee4 e2 = mapper.readValue(s, Employee4.class);
23 | PrintUtils.print("JSON转换为对象", e2);
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/json-example/jackson-example/src/main/java/io/github/biezhi/json/jackson/model/Employee.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.json.jackson.model;
2 |
3 | import com.fasterxml.jackson.annotation.JsonProperty;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class Employee {
8 |
9 | @JsonProperty("employee-name")
10 | private String name;
11 |
12 | @JsonProperty("employee-dept")
13 | private String dept;
14 |
15 | }
--------------------------------------------------------------------------------
/json-example/jackson-example/src/main/java/io/github/biezhi/json/jackson/model/Employee2.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.json.jackson.model;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
4 | import lombok.Data;
5 |
6 | @Data
7 | public class Employee2 {
8 |
9 | private String name;
10 |
11 | private String dept;
12 |
13 | @JsonIgnore
14 | private String address;
15 | }
--------------------------------------------------------------------------------
/json-example/jackson-example/src/main/java/io/github/biezhi/json/jackson/model/Employee3.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.json.jackson.model;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 | import lombok.Data;
5 |
6 | @Data
7 | @JsonIgnoreProperties({"dept", "address"})
8 | public class Employee3 {
9 |
10 | private String name;
11 | private String dept;
12 | private String address;
13 | }
--------------------------------------------------------------------------------
/json-example/jackson-example/src/main/java/io/github/biezhi/json/jackson/model/Employee4.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.json.jackson.model;
2 |
3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4 | import lombok.Data;
5 |
6 | @Data
7 | @JsonIgnoreProperties(ignoreUnknown = true)
8 | public class Employee4 {
9 |
10 | private String name;
11 | private String dept;
12 | private String address;
13 |
14 | }
--------------------------------------------------------------------------------
/json-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | json-example
13 | pom
14 |
15 |
16 | fastjson-example
17 | gson-exmaple
18 | jackson-example
19 |
20 |
21 |
22 |
23 | io.github.biezhi
24 | common-beans
25 | 1.0-SNAPSHOT
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/log-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | log-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/log-example/commons-logging-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | commons-logging-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/log-example/commons-logging-example/commons-logging-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/log-example/commons-logging-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | log-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | commons-logging-example
13 |
14 |
15 |
16 | commons-logging
17 | commons-logging
18 | 1.2
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/log-example/commons-logging-example/src/main/java/io/github/biezhi/commons/logging/Example1.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.commons.logging;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | /**
7 | * 基础示例
8 | */
9 | public class Example1 {
10 |
11 | private static Log log = LogFactory.getLog(Example1.class);
12 |
13 | public static void main(String[] args) {
14 | // debug不输出,默认为 info 级别
15 | log.debug("我爱编程,编程使我快乐。");
16 | log.info("我爱编程,编程使我快乐。");
17 | log.warn("我爱编程,编程使我快乐。");
18 | log.error("我爱编程,编程使我快乐。");
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/log-example/commons-logging-example/src/main/java/io/github/biezhi/commons/logging/Example2.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.commons.logging;
2 |
3 | import org.apache.commons.logging.Log;
4 | import org.apache.commons.logging.LogFactory;
5 |
6 | /**
7 | * 自定义属性
8 | *
9 | * 自定义日期格式化
10 | */
11 | public class Example2 {
12 | private static Log log = null;
13 |
14 | static {
15 | System.setProperty("java.util.logging.SimpleFormatter.format", "[%1$tF %1$tT] [%4$s] %5$s %n");
16 | log = LogFactory.getLog(Example2.class);
17 | }
18 |
19 | public static void main(String[] args) {
20 | log.info("我爱编程,编程使我快乐。");
21 | }
22 |
23 | }
--------------------------------------------------------------------------------
/log-example/log-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/log-example/log4j-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | log4j-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/log-example/log4j-example/log4j-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/log-example/log4j-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | log-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | log4j-example
13 |
14 |
15 |
16 | log4j
17 | log4j
18 | 1.2.17
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/log-example/log4j-example/src/main/java/io/github/biezhi/log4j/Example.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.log4j;
2 |
3 | import org.apache.log4j.Logger;
4 |
5 | public class Example {
6 |
7 | final static Logger LOGGER = Logger.getLogger(Example.class);
8 |
9 | public static void main(String[] args) {
10 | LOGGER.debug("我爱编程,编程使我快乐。");
11 | LOGGER.info("我爱编程,编程使我快乐。");
12 | LOGGER.warn("我爱编程,编程使我快乐。");
13 | LOGGER.error("我爱编程,编程使我快乐。");
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/log-example/log4j-example/src/main/resources/log4j.properties:
--------------------------------------------------------------------------------
1 | # Set root logger level to DEBUG. myAppender is a reference (can be any name)
2 | log4j.rootLogger=DEBUG, myAppender
3 | # myAppender is set to be a ConsoleAppender.
4 | log4j.appender.myAppender=org.apache.log4j.ConsoleAppender
5 | # Assigning layout pattern to myAppender.
6 | log4j.appender.myAppender.layout=org.apache.log4j.PatternLayout
7 | # Formatting pattern, see also org.apache.log4j.PatternLayout docs for right side specifiers:
8 | log4j.appender.myAppender.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss:SSS} %5p %t %c{2}:%L - %m%n
9 |
10 | # 保存文件
11 |
12 | #log4j.rootLogger=INFO, myFile
13 | #log4j.appender.myFile=org.apache.log4j.FileAppender
14 | #log4j.appender.myFile.File=d:\\logs\\someName.txt
15 | #log4j.appender.myFile.layout=org.apache.log4j.PatternLayout
16 | #log4j.appender.myFile.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss:SSS} %5p %t %c{2}:%L - %m%n
--------------------------------------------------------------------------------
/log-example/logback-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | logback-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/log-example/logback-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | log-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | logback-example
13 |
14 |
15 |
16 | ch.qos.logback
17 | logback-classic
18 | 1.2.3
19 |
20 |
21 |
--------------------------------------------------------------------------------
/log-example/logback-example/src/main/java/io/github/biezhi/logback/LogbackExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.logback;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | public class LogbackExample {
7 |
8 | private final static Logger LOGGER = LoggerFactory.getLogger(LogbackExample.class);
9 |
10 | public static void main(String[] args) {
11 | LOGGER.debug("我爱编程,编程使我快乐。");
12 | LOGGER.info("我爱编程,编程使我快乐。");
13 | LOGGER.warn("我爱编程,编程使我快乐。");
14 | LOGGER.error("我爱编程,编程使我快乐。");
15 | }
16 |
17 | }
--------------------------------------------------------------------------------
/log-example/logback-example/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
8 |
9 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/log-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | log-example
13 | pom
14 |
15 | log4j-example
16 | logback-example
17 | commons-logging-example
18 | slf4j-example
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/log-example/slf4j-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | slf4j-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/log-example/slf4j-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | log-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | slf4j-example
13 |
14 |
15 |
16 | org.slf4j
17 | slf4j-api
18 | 1.7.25
19 |
20 |
21 | ch.qos.logback
22 | logback-classic
23 | 1.2.3
24 |
25 |
26 |
--------------------------------------------------------------------------------
/log-example/slf4j-example/src/main/java/io/github/biezhi/slf4j/Hello.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.slf4j;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | /**
7 | * @author biezhi
8 | * @date 2018/1/16
9 | */
10 | public class Hello {
11 |
12 | private static Logger LOGGER = LoggerFactory.getLogger(Hello.class);
13 |
14 | public static void doSomething() {
15 | LOGGER.info("在 Hello 类中的 INFO 消息");
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/log-example/slf4j-example/src/main/java/io/github/biezhi/slf4j/Slf4jExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.slf4j;
2 |
3 | import org.slf4j.Logger;
4 | import org.slf4j.LoggerFactory;
5 |
6 | /**
7 | * Slf4j + logback 示例
8 | *
9 | * @author biezhi
10 | * @date 2018/1/16
11 | */
12 | public class Slf4jExample {
13 |
14 | private static final Logger LOGGER = LoggerFactory.getLogger(Slf4jExample.class);
15 |
16 | public static void main(String[] args) {
17 | LOGGER.debug("我爱编程,编程使我快乐。");
18 | LOGGER.info("我爱编程,编程使我快乐。");
19 | LOGGER.warn("我爱编程,编程使我快乐。");
20 | LOGGER.error("我爱编程,编程使我快乐。");
21 | Hello.doSomething();
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/log-example/slf4j-example/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | %d{yyyy-MM-dd HH:mm:ss:SSS} %5p %t %c{2}:%L - %m%n
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/metrics-example/README.md:
--------------------------------------------------------------------------------
1 |
2 | - [Metrics 是个什么鬼 之入门教程](http://wuchong.me/blog/2015/08/01/getting-started-with-metrics/)
3 | - [Metrics介绍和Spring的集成](http://colobu.com/2014/08/08/Metrics-and-Spring-Integration/)
4 |
5 |
--------------------------------------------------------------------------------
/metrics-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | metrics-example
13 |
14 |
15 |
16 | io.dropwizard.metrics
17 | metrics-core
18 | 4.0.2
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/metrics-example/src/main/java/io/github/biezhi/metrics/GaugeExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.metrics;
2 |
3 | import com.codahale.metrics.ConsoleReporter;
4 | import com.codahale.metrics.Gauge;
5 | import com.codahale.metrics.MetricRegistry;
6 |
7 | import java.util.LinkedList;
8 | import java.util.Queue;
9 | import java.util.concurrent.TimeUnit;
10 |
11 | /**
12 | * 衡量一个待处理队列中任务的个数
13 | */
14 | public class GaugeExample {
15 |
16 | public static Queue q = new LinkedList<>();
17 |
18 | public static void main(String[] args) throws InterruptedException {
19 | MetricRegistry registry = new MetricRegistry();
20 | ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).build();
21 | reporter.start(1, TimeUnit.SECONDS);
22 | registry.register(MetricRegistry.name(GaugeExample.class, "queue", "size"),
23 | (Gauge) () -> q.size());
24 |
25 | while (true) {
26 | Thread.sleep(1000);
27 | q.add("Job-xxx");
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/metrics-example/src/main/java/io/github/biezhi/metrics/TimerExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.metrics;
2 |
3 | import com.codahale.metrics.ConsoleReporter;
4 | import com.codahale.metrics.MetricRegistry;
5 | import com.codahale.metrics.Timer;
6 |
7 | import java.util.Random;
8 | import java.util.concurrent.TimeUnit;
9 |
10 | /**
11 | * Timer其实是 Histogram 和 Meter 的结合, histogram 某部分代码/调用的耗时, meter统计TPS。
12 | */
13 | public class TimerExample {
14 |
15 | public static Random random = new Random();
16 |
17 | public static void main(String[] args) throws InterruptedException {
18 | MetricRegistry registry = new MetricRegistry();
19 | ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).build();
20 | reporter.start(1, TimeUnit.SECONDS);
21 | Timer timer = registry.timer(MetricRegistry.name(TimerExample.class, "get-latency"));
22 | Timer.Context ctx;
23 | while (true) {
24 | ctx = timer.time();
25 | Thread.sleep(random.nextInt(1000));
26 | ctx.stop();
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/mq-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | mq-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/mq-example/kafka-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | kafka-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/mq-example/kafka-example/kafka-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/mq-example/kafka-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | mq-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | kafka-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/mq-example/mq-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/mq-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | mq-example
13 | pom
14 |
15 | kafka-example
16 | rocketmq-example
17 | rabbitmq-example
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/mq-example/rabbitmq-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | rabbitmq-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/mq-example/rabbitmq-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | mq-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | rabbitmq-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/mq-example/rabbitmq-example/rabbitmq-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/mq-example/rocketmq-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | rocketmq-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/mq-example/rocketmq-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | mq-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | rocketmq-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/mq-example/rocketmq-example/rocketmq-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/network-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | network-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/network-example/mina-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | mina-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/network-example/mina-example/mina-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/network-example/mina-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | network-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | mina-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/network-example/netty-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | netty-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/network-example/netty-example/netty-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/network-example/netty-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | network-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | netty-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/network-example/network-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/network-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | network-example
13 | pom
14 |
15 | netty-example
16 | mina-example
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/orm-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | orm-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/blade-jdbc-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | blade-jdbc-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/blade-jdbc-example/blade-jdbc-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/orm-example/blade-jdbc-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | orm-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | blade-jdbc-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/orm-example/dbutils-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | dbutils-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/dbutils-example/dbutils-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/orm-example/dbutils-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | orm-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | dbutils-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/orm-example/hibernate-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | hibernate-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/hibernate-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | orm-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | hibernate-example
13 |
14 |
15 |
16 | org.hibernate
17 | hibernate-core
18 | 5.2.10.Final
19 |
20 |
21 | com.h2database
22 | h2
23 | 1.4.193
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/orm-example/hibernate-example/src/main/java/io/github/biezhi/hibernate/Person.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.hibernate;
2 |
3 | import lombok.Data;
4 | import javax.persistence.Column;
5 | import javax.persistence.Entity;
6 | import javax.persistence.GeneratedValue;
7 | import javax.persistence.Id;
8 |
9 | /**
10 | * @author biezhi
11 | * @date 2018/1/16
12 | */
13 | @Data
14 | @Entity
15 | public class Person {
16 | @Id
17 | @GeneratedValue
18 | private int id;
19 | @Column(name = "FULL_NAME")
20 | private String name;
21 | private int age;
22 |
23 | public Person() {
24 | }
25 |
26 | public Person(String name, int age) {
27 | this.name = name;
28 | this.age = age;
29 | }
30 | }
--------------------------------------------------------------------------------
/orm-example/hibernate-example/src/main/resources/hibernate.cfg.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 | org.h2.Driver
9 | jdbc:h2:mem:test;DB_CLOSE_DELAY=-1
10 | org.hibernate.dialect.H2Dialect
11 | true
12 | create
13 |
14 |
15 |
--------------------------------------------------------------------------------
/orm-example/jooq-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | jooq-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/jooq-example/jooq-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/orm-example/jooq-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | orm-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | jooq-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/orm-example/mybatis-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | mybatis-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/mybatis-example/src/main/java/io/github/biezhi/mybatis/mapper/VillageMapper.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.mybatis.mapper;
2 |
3 | import org.apache.ibatis.annotations.Update;
4 |
5 | /**
6 | * @author biezhi
7 | * @date 2018/1/16
8 | */
9 | public interface VillageMapper {
10 | @Update("CREATE TABLE `village` (\n" +
11 | "\t`id` INT(10) NOT NULL AUTO_INCREMENT,\n" +
12 | "\t`name` VARCHAR(50) NULL DEFAULT NULL,\n" +
13 | "\t`district` VARCHAR(50) NULL DEFAULT NULL,\n" +
14 | "\tPRIMARY KEY (`id`)\n" +
15 | ")")
16 | void schema();
17 | }
18 |
--------------------------------------------------------------------------------
/orm-example/mybatis-example/src/main/java/io/github/biezhi/mybatis/model/TransactionToken.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.mybatis.model;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class TransactionToken {
7 | private Long id = -1L;
8 | private String transaction = "";
9 | private String token = "";
10 |
11 | }
--------------------------------------------------------------------------------
/orm-example/mybatis-example/src/main/java/io/github/biezhi/mybatis/model/Village.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.mybatis.model;
2 |
3 | import lombok.Data;
4 |
5 | @Data
6 | public class Village {
7 | private Integer id;
8 | private String name;
9 | private String district;
10 | }
--------------------------------------------------------------------------------
/orm-example/mybatis-example/src/main/java/io/github/biezhi/mybatis/utils/MyBatisUtil.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.mybatis.utils;
2 |
3 | import io.github.biezhi.mybatis.mapper.TransactionTokenMapper;
4 | import org.apache.ibatis.io.Resources;
5 | import org.apache.ibatis.session.SqlSessionFactory;
6 | import org.apache.ibatis.session.SqlSessionFactoryBuilder;
7 |
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | public class MyBatisUtil {
12 |
13 | private static SqlSessionFactory sqlSessionFactory;
14 |
15 | static {
16 | String resource = "mybatis-config.xml";
17 | InputStream inputStream;
18 | try {
19 | inputStream = Resources.getResourceAsStream(resource);
20 | sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
21 | sqlSessionFactory.getConfiguration().addMapper(TransactionTokenMapper.class);
22 | } catch (IOException e) {
23 | e.printStackTrace();
24 | }
25 | }
26 |
27 | public static SqlSessionFactory getSqlSessionFactory() {
28 | return sqlSessionFactory;
29 | }
30 | }
--------------------------------------------------------------------------------
/orm-example/mybatis-example/src/main/resources/log4j.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/orm-example/orm-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/orm-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | orm-example
13 | pom
14 |
15 | mybatis-example
16 | hibernate-example
17 | sql2o-example
18 | dbutils-example
19 | blade-jdbc-example
20 | jooq-example
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/orm-example/sql2o-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | sql2o-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/orm-example/sql2o-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | orm-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | sql2o-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/orm-example/sql2o-example/sql2o-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/qrcode-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | qrcode-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/qrcode-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | qrcode-example
13 | pom
14 |
15 |
16 | zxing-example
17 | qrgen-example
18 |
19 |
20 |
--------------------------------------------------------------------------------
/qrcode-example/qrcode-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/qrcode-example/qrgen-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | qrgen-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/qrcode-example/qrgen-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | qrcode-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | qrgen-example
13 |
14 |
15 |
16 | net.glxn.qrgen
17 | javase
18 | 2.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/qrcode-example/qrgen-example/src/main/java/io/github/biezhi/qrgen/URLQRCodeExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.qrgen;
2 |
3 | import net.glxn.qrgen.core.image.ImageType;
4 | import net.glxn.qrgen.javase.QRCode;
5 | import java.io.*;
6 |
7 | public class URLQRCodeExample {
8 |
9 | public static void main(String... args){
10 | ByteArrayOutputStream bout =
11 | QRCode.from("https://github.com/biezhi")
12 | .withSize(250, 250)
13 | .to(ImageType.PNG)
14 | .stream();
15 | try {
16 | OutputStream out = new FileOutputStream("qr-code.png");
17 | bout.writeTo(out);
18 | out.flush();
19 | out.close();
20 |
21 | } catch (IOException e) {
22 | e.printStackTrace();
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/qrcode-example/zxing-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | zxing-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/qrcode-example/zxing-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | qrcode-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | zxing-example
13 |
14 |
15 |
16 | com.google.zxing
17 | core
18 | 3.3.1
19 |
20 |
21 | com.google.zxing
22 | javase
23 | 3.3.1
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/rss-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | rss-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/rss-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | rss-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/rss-example/rss-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/task-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | task-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/task-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | task-example
13 | pom
14 |
15 | quartz-example
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/task-example/quartz-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | quartz-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/task-example/quartz-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | task-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | quartz-example
13 |
14 |
15 |
16 | org.quartz-scheduler
17 | quartz
18 | 2.3.0
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/task-example/quartz-example/src/main/java/io/github/biezhi/quartz/CronTriggerExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.quartz;
2 |
3 | import io.github.biezhi.quartz.job.HelloJob;
4 | import org.quartz.*;
5 | import org.quartz.impl.StdSchedulerFactory;
6 |
7 | import java.time.LocalDateTime;
8 |
9 | /**
10 | * cron 表达式触发器例子
11 | */
12 | public class CronTriggerExample {
13 |
14 | public static void main(String[] args) throws SchedulerException, InterruptedException {
15 |
16 | JobDetail job = JobBuilder.newJob(HelloJob.class).withIdentity("myjob1", "mygroup1").build();
17 | System.out.println("启动时间: " + LocalDateTime.now().toString());
18 |
19 | // 每5秒调用一次
20 | Trigger trigger = TriggerBuilder.newTrigger().withIdentity("mytrigger2", "mygroup2")
21 | .withSchedule(CronScheduleBuilder.cronSchedule("0/5 * * * * ?"))
22 | .build();
23 |
24 | Scheduler scheduler = new StdSchedulerFactory().getScheduler();
25 | scheduler.start();
26 | scheduler.scheduleJob(job, trigger);
27 | // 30 秒后关闭
28 | Thread.sleep(30_000);
29 | scheduler.shutdown(true);
30 | }
31 | }
--------------------------------------------------------------------------------
/task-example/quartz-example/src/main/java/io/github/biezhi/quartz/job/ExceptionJob.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.quartz.job;
2 |
3 | import org.quartz.Job;
4 | import org.quartz.JobExecutionContext;
5 | import org.quartz.JobExecutionException;
6 |
7 | public class ExceptionJob implements Job {
8 |
9 | @Override
10 | public void execute(JobExecutionContext context) throws JobExecutionException {
11 | System.out.println("五秒一次的体验...");
12 | throw new JobExecutionException("异常消息: XXX出错了");
13 | }
14 |
15 | }
--------------------------------------------------------------------------------
/task-example/quartz-example/src/main/java/io/github/biezhi/quartz/job/HelloJob.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.quartz.job;
2 |
3 | import java.time.LocalDateTime;
4 |
5 | import org.quartz.Job;
6 | import org.quartz.JobDetail;
7 | import org.quartz.JobExecutionContext;
8 | import org.quartz.JobKey;
9 |
10 | public class HelloJob implements Job {
11 |
12 | @Override
13 | public void execute(JobExecutionContext context) {
14 | JobDetail jobDetail = context.getJobDetail();
15 | JobKey key = jobDetail.getKey();
16 | System.out.println("当前 Job Key: " + key + ", 当前时间: " + LocalDateTime.now().toString());
17 | }
18 |
19 | }
--------------------------------------------------------------------------------
/task-example/task-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/template-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | template-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/template-example/freemarker-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | freemarker-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/template-example/freemarker-example/freemarker-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/template-example/freemarker-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | template-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | freemarker-example
13 |
14 |
15 |
16 | org.freemarker
17 | freemarker
18 | 2.3.23
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/template-example/freemarker-example/src/main/resources/hello.ftl:
--------------------------------------------------------------------------------
1 | FreeMarker Template example: ${message}
2 |
3 | =======================
4 | === County List ====
5 | =======================
6 | <#list countries as country>
7 | ${country_index + 1}. ${country}
8 | #list>
--------------------------------------------------------------------------------
/template-example/jetbrick-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | jetbrick-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/template-example/jetbrick-example/jetbrick-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/template-example/jetbrick-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | template-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | jetbrick-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/template-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | template-example
13 | pom
14 |
15 | freemarker-example
16 | velocity-example
17 | jetbrick-example
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/template-example/template-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/template-example/velocity-example/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | velocity-example
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.m2e.core.maven2Builder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.m2e.core.maven2Nature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/template-example/velocity-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | template-example
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | velocity-example
13 |
14 |
15 |
--------------------------------------------------------------------------------
/template-example/velocity-example/velocity-example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/tensorflow-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | tensorflow-example
13 |
14 |
15 | io.github.biezhi.tensorflow.HelloTF
16 |
17 |
18 |
19 |
20 | org.tensorflow
21 | tensorflow
22 | 1.5.0
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/yaml-example/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | java-library-examples
7 | io.github.biezhi
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | yaml-example
13 |
14 |
15 |
16 | org.yaml
17 | snakeyaml
18 | 1.19
19 |
20 |
21 |
--------------------------------------------------------------------------------
/yaml-example/src/main/java/io/github/biezhi/yaml/JavaToYamlExample.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.yaml;
2 |
3 | import org.yaml.snakeyaml.Yaml;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | /**
9 | * Map 转 yaml配置
10 | */
11 | public class JavaToYamlExample {
12 |
13 | public static void main(String[] args) {
14 | Map> map = createMap();
15 | Yaml yaml = new Yaml();
16 | String output = yaml.dump(map);
17 | System.out.println(output);
18 | }
19 |
20 | private static Map> createMap() {
21 | Map> map = new HashMap<>();
22 | for (int i = 1; i <= 3; i++) {
23 | Map map2 = new HashMap<>();
24 | map2.put("key1" + i, "value1" + i);
25 | map2.put("key2" + i, "value2" + i);
26 | map2.put("key3" + i, "value4" + i);
27 | map.put("key" + i, map2);
28 | }
29 | return map;
30 | }
31 | }
--------------------------------------------------------------------------------
/yaml-example/src/main/java/io/github/biezhi/yaml/LoadList.java:
--------------------------------------------------------------------------------
1 | package io.github.biezhi.yaml;
2 |
3 | import org.yaml.snakeyaml.Yaml;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | public class LoadList {
9 |
10 | public static void main(String[] args) throws IOException {
11 | loadFromFile("/fruits.yml");
12 | }
13 |
14 | private static void loadFromFile(String path) throws IOException {
15 | System.out.printf("-- loading from %s --%n", path);
16 | Yaml yaml = new Yaml();
17 | try (InputStream in = LoadList.class.getResourceAsStream(path)) {
18 | Iterable