From b91a03056a358327cee5a3f9cd8ebf60b37407c6 Mon Sep 17 00:00:00 2001 From: Wendal Chen Date: Fri, 29 Dec 2017 12:04:22 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E6=9B=B4=E6=96=B0demo-maker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nutzboot-demo/nutzboot-demo-maker/pom.xml | 2 - .../java/io/nutz/demo/maker/MainLauncher.java | 12 ++++- .../src/main/resources/static/index.html | 8 +++ .../main/resources/static/thymeleaf/_pom.xml | 52 ++++++++----------- .../src/main/java/_package/MainLauncher.java | 33 +++--------- .../main/java/_package/module/TimeModule.java | 28 ++++++++++ .../src/main/resources/static/index.html | 17 ++++++ pom.xml | 10 ++++ 8 files changed, 103 insertions(+), 59 deletions(-) create mode 100644 nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/module/TimeModule.java create mode 100644 nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/resources/static/index.html diff --git a/nutzboot-demo/nutzboot-demo-maker/pom.xml b/nutzboot-demo/nutzboot-demo-maker/pom.xml index f3d6712c..129d14ab 100644 --- a/nutzboot-demo/nutzboot-demo-maker/pom.xml +++ b/nutzboot-demo/nutzboot-demo-maker/pom.xml @@ -14,12 +14,10 @@ org.nutz nutzboot-starter-jetty - ${project.version} org.nutz nutzboot-starter-nutz-mvc - ${project.version} org.slf4j diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/java/io/nutz/demo/maker/MainLauncher.java b/nutzboot-demo/nutzboot-demo-maker/src/main/java/io/nutz/demo/maker/MainLauncher.java index 06b29764..64819ece 100644 --- a/nutzboot-demo/nutzboot-demo-maker/src/main/java/io/nutz/demo/maker/MainLauncher.java +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/java/io/nutz/demo/maker/MainLauncher.java @@ -75,11 +75,21 @@ protected void build(File tmpRoot, NutMap params) throws IOException { String log4jPropertiesStr = _render("src/main/resources/log4j.properties", params); _write(new File(tmpRoot, "src/main/resources/log4j.properties"), log4jPropertiesStr); - // 生成MainLauncher + + String indexHtmlStr = _render("src/main/resources/static/index.html", params); + _write(new File(tmpRoot, "src/main/resources/static/index.html"), indexHtmlStr); + + String packagePath = params.getString("packageName").replace('.', '/'); + + // 生成MainLauncher String mainLauncherStr = _render("src/main/java/_package/MainLauncher.java", params); _write(new File(tmpRoot, "src/main/java/"+packagePath + "/MainLauncher.java"), mainLauncherStr); + // 生成TimeModule + String timeModuleStr = _render("src/main/java/_package/module/TimeModule.java", params); + _write(new File(tmpRoot, "src/main/java/"+packagePath + "/module/TimeModule.java"), timeModuleStr); + // maven wrapper from https://github.com/takari/maven-wrapper String key = tmpRoot.getName(); diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/index.html b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/index.html index 9d31629c..ef09f85e 100644 --- a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/index.html +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/index.html @@ -162,6 +162,11 @@ + + + + + 立即创建 @@ -297,6 +302,9 @@ }, wkcache: { enable: false + }, + feign: { + enable: false } }, nbJson: "", diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/_pom.xml b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/_pom.xml index d043d943..2a2cca84 100644 --- a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/_pom.xml +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/_pom.xml @@ -3,55 +3,59 @@ 4.0.0 io.nutz demo - 2.0-SNAPSHOT + 1.0-SNAPSHOT jar - 1.7.25 - 4.12 - 1.2.17 UTF-8 + + + + org.nutz + nutzboot-parent + ${nutzboot.version} + pom + import + + + org.nutz nutzboot-starter - ${nutzboot.version} + + + org.nutz + nutzboot-starter-swagger org.nutz nutzboot-starter-jetty - ${nutzboot.version} org.nutz nutzboot-starter-nutz-mvc - ${nutzboot.version} org.nutz nutzboot-starter-nutz-dao - ${nutzboot.version} org.nutz nutzboot-starter-jdbc - ${nutzboot.version} com.alibaba druid - 1.1.5 org.nutz nutzboot-starter-redis - ${nutzboot.version} org.nutz nutzboot-starter-quartz - ${nutzboot.version} org.nutz @@ -61,89 +65,76 @@ org.nutz nutzboot-starter-tomcat - ${nutzboot.version} org.nutz nutzboot-starter-undertow - ${nutzboot.version} org.nutz nutzboot-starter-dubbo - ${nutzboot.version} org.nutz nutzboot-starter-zbus - ${nutzboot.version} org.nutz nutzboot-starter-ngrok - ${nutzboot.version} org.nutz nutzboot-starter-sharding-jdbc - ${nutzboot.version} org.nutz nutzboot-starter-beetlsql - ${nutzboot.version} org.nutz nutzboot-starter-mongodb - ${nutzboot.version} org.nutz nutzboot-starter-shiro - ${nutzboot.version} org.nutz nutzboot-starter-beetl - ${nutzboot.version} org.nutz nutzboot-starter-thymeleaf - ${nutzboot.version} org.nutz nutzboot-starter-disque - ${nutzboot.version} org.nutz nutzboot-starter-uflo - ${nutzboot.version} org.nutz nutzboot-starter-urule - ${nutzboot.version} org.nutz nutzboot-starter-ureport - ${nutzboot.version} org.nutz nutzboot-starter-wkcache - ${nutzboot.version} + + + org.nutz + nutzboot-starter-feign org.slf4j slf4j-log4j12 - ${slf4j.version} - + com.h2database h2 1.4.196 @@ -151,7 +142,6 @@ junit junit - ${junit.version} test diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/MainLauncher.java b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/MainLauncher.java index 1932a62b..8e271c10 100644 --- a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/MainLauncher.java +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/MainLauncher.java @@ -1,28 +1,9 @@ package [[${params.packageName}]]; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - import org.nutz.boot.NbApp; import org.nutz.ioc.impl.PropertiesProxy; -import org.nutz.ioc.loader.annotation.Inject; -import org.nutz.ioc.loader.annotation.IocBean; -import org.nutz.lang.Files; -import org.nutz.lang.Streams; -import org.nutz.lang.random.R; -import org.nutz.lang.util.Disks; -import org.nutz.lang.util.FileVisitor; -import org.nutz.lang.util.NutMap; -import org.nutz.mvc.Mvcs; -import org.nutz.mvc.adaptor.JsonAdaptor; -import org.nutz.mvc.annotation.AdaptBy; -import org.nutz.mvc.annotation.At; -import org.nutz.mvc.annotation.Ok; -import org.nutz.mvc.annotation.Param; +import org.nutz.ioc.loader.annotation.*; +import org.nutz.mvc.annotation.*; @IocBean(create="init", depose="depose") public class MainLauncher { @@ -33,12 +14,14 @@ public class MainLauncher { @At("/") @Ok("->:/index.html") public void index() {} - - public void init() {} - public void depose() {} + + public void init() { + // NB自身初始化完成后会调用这个方法 + } + public void depose() {} public static void main(String[] args) throws Exception { - new NbApp(MainLauncher.class).run(); + new NbApp().run(); } } diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/module/TimeModule.java b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/module/TimeModule.java new file mode 100644 index 00000000..c1dbe675 --- /dev/null +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/java/_package/module/TimeModule.java @@ -0,0 +1,28 @@ +package [[${params.packageName}]].module; + + +import org.nutz.ioc.impl.PropertiesProxy; +import org.nutz.ioc.loader.annotation.*; +import org.nutz.mvc.annotation.*; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + +@Api("time") +@At("/time") +@IocBean(create="init", depose="depose") +public class TimeModule { + + @Inject + protected PropertiesProxy conf; + + @ApiOperation(value = "获取当前毫秒数", notes = "服务器端的时间", httpMethod="GET", response=Long.class) + @At + @Ok("raw") + public long now() { + return System.currentTimeMillis(); + } + + public void init() {} + public void depose() {} + +} diff --git a/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/resources/static/index.html b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/resources/static/index.html new file mode 100644 index 00000000..f5e32e05 --- /dev/null +++ b/nutzboot-demo/nutzboot-demo-maker/src/main/resources/static/thymeleaf/src/main/resources/static/index.html @@ -0,0 +1,17 @@ + + + + +Hello, So NB! + + +
+

Hello, So NB!

+
+
+

+ 查看api文档(由Swagger生成) +

+
+ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9c0609ae..43088a7f 100644 --- a/pom.xml +++ b/pom.xml @@ -477,6 +477,11 @@ nutzboot-starter-jetty ${nutzboot.version}
+ + org.nutz + nutzboot-starter-swagger + ${nutzboot.version} + org.nutz nutzboot-starter-feign @@ -592,6 +597,11 @@ nutzboot-starter-wkcache ${nutzboot.version} + + javassist + javassist + 3.12.1.GA +