Skip to content

Commit

Permalink
update: 更新demo-maker
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Dec 29, 2017
1 parent 4431d16 commit b91a030
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 59 deletions.
2 changes: 0 additions & 2 deletions nutzboot-demo/nutzboot-demo-maker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-jetty</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-nutz-mvc</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
<el-form-item label="wkcache">
<el-switch v-model="nb.wkcache.enable"></el-switch>
</el-form-item>

<!--feign-->
<el-form-item label="feign">
<el-switch v-model="nb.feign.enable"></el-switch>
</el-form-item>

<el-form-item>
<el-button type="primary" @click="onSubmit">立即创建</el-button>
Expand Down Expand Up @@ -297,6 +302,9 @@
},
wkcache: {
enable: false
},
feign: {
enable: false
}
},
nbJson: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,59 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.nutz</groupId>
<artifactId>demo</artifactId>
<version>2.0-SNAPSHOT</version>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<slf4j.version>1.7.25</slf4j.version>
<nutzboot.version th:text="${params.version}"></nutzboot.version>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-parent</artifactId>
<version>${nutzboot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-swagger</artifactId>
</dependency>
<dependency th:if="${params.jetty.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-jetty</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.nutzmvc.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-nutz-mvc</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.nutzdao.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-nutz-dao</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.jdbc.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-jdbc</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.jdbc.enable}">
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.5</version>
</dependency>
<dependency th:if="${params.redis.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-redis</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.quartz.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-quartz</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.weixin.enable}">
<groupId>org.nutz</groupId>
Expand All @@ -61,97 +65,83 @@
<dependency th:if="${params.tomcat.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-tomcat</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.undertow.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-undertow</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.dubbo.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-dubbo</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.zbus.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-zbus</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.ngrok.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-ngrok</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.shardingjdbc.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-sharding-jdbc</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.beetlsql.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-beetlsql</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.mongo.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-mongodb</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.shiro.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-shiro</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.beetl.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-beetl</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.thymeleaf.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-thymeleaf</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.disque.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-disque</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.uflo2.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-uflo</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.urule.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-urule</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.ureport.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-ureport</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.wkcache.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-wkcache</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency th:if="${params.feign.enable}">
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-feign</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<dependency th:if="${params.jdbc.enable || params.shardingjdbc.enable}">
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.196</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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() {}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello, So NB!</title>
</head>
<body>
<div>
<h2>Hello, So NB!</h2>
</div>
<div>
<h2>
<a href="swagger/index.html">查看api文档(由Swagger生成)</a>
</h2>
</div>
</body>
</html>
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,11 @@
<artifactId>nutzboot-starter-jetty</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-swagger</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutzboot-starter-feign</artifactId>
Expand Down Expand Up @@ -592,6 +597,11 @@
<artifactId>nutzboot-starter-wkcache</artifactId>
<version>${nutzboot.version}</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
Expand Down

0 comments on commit b91a030

Please sign in to comment.