NutzCN Logo
精华 NutzWk 5.0.x 微服务分布式版本开发及部署说明
发布于 167天前 作者 Wizzercn 4228 次浏览 复制 上一个帖子 下一个帖子
标签:

NutzWk 5.x 已发布一段时间,这段时间基于此版本开发了智慧水务系统(NB-IOT)、某物联网平台、某设备租赁平台、某智慧睡眠平台、某智慧园区项目等,开发和部署过程中遇到一些小问题,开这个帖子把一些经验分享出来省的大家走弯路。

项目地址1: https://github.com/Wizzercn/NutzWk
项目地址2: https://gitee.com/wizzer/NutzWk

1、运行环境
其实项目readme和wk-wiki 已经写的很清楚了,在此强调一下,不是说非这些版本不可,但对于新手来说最好版本号保持一致,能跑起来了您再折腾玩~~

JDK 8 162 +
Maven 3.5.3 +
Redis 4.0.8 +
MySql 5.7 +
Zookeeper 3.4.11 +

2、开发环境
一般建议使用IDEA进行开发,因为是maven多模块的项目,直接用IDEA打开项目根目录,它会通过maven下载jar包,自动构建项目
然后如何启动项目呢,有很多种方式,简单说几个:
1)打开每个NB项目(nutzboot简称)项目里的main类,右击运行,例如 cn.wizzer.sys.commons.core.***MainLauncher
2)通过IDEA 的Run 配置 Application 运行,详见 https://github.com/Wizzercn/NutzWk/blob/nutzboot-dubbo/wk-wiki/01.QuickStart/01.02.Start.md
3)命令行在NB项目根目录运行mvn compile nutzboot:run 或者IDEA右侧Maven管理界面里通过插件运行,,详见 https://github.com/nutzam/nutzboot-maven-plugin

3、启动顺序
保证MySQL、Redis、Zookeeper 都正常启动且为默认端口及默认配置(当然这些配置项可以在application.properties 修改的)
1)MySQL创建一个空白数据库,编码格式为UTF-8,数据库名称 nutzwk_nb
2)NB项目的模块启动顺序是 sys --> cms[可选] --> wx[可选] --> task[可选] --> web-platform --> web-api[可选]
3)如上所述,如果想运行访问后台,只需要启动 sys 和 web-platform即可,注意是有启动顺序的,其他模块需要用就启
4)task 定时任务是依赖于sys的,而web-platform系统管理对定时任务管理是依赖于 task模块的,如果你想让task独立运行并且不需要通过页面进行管理,自己少做改动即可,不是不可以哦

4、部署注意事项
1)因为登录页面对密码进行了RSA加密,有时候部署会遇到怎么也登录不了,而后台抛异常 java.lang.SecurityException: JCE cannot authenticate the provider BC 的情况,解决方法在代码注释里已写明了,不过很少有人去看
https://github.com/Wizzercn/NutzWk/blob/nutzboot-dubbo/wk-app/wk-nb-web-platform/src/main/java/cn/wizzer/app/web/commons/shiro/filter/PlatformAuthenticationFilter.java

1、编辑文件 /usr/java/jdk1.8.0_162/jre/lib/security/java.security
     在9下面添加 security.provider.10=org.bouncycastle.jce.provider.BouncyCastleProvider
2、拷贝 bcprov-jdk16-143.jar 和 bcprov-jdk15-135.jar 到 /usr/java/jdk1.8.0_162/jre/lib/ext 目录下
3、别问我上面两个文件怎么找……

(如果您是https的话可以把RSA加密方式改掉弃用哦)
2)服务器注意事项:服务器时间同步做没做、hosts里配没配主机名hostname和127.0.0.1的映射关系、内存够不够用(有没有给jar指定内存大小)等

5、其他
1)请关注 NutzWk 的动态,有新的版本发布建议及时更新,往往会修复问题或新增功能
2)如果 NutzWk 给了您帮助,或已用于生产, https://wizzer.cn/donation 欢迎打赏一定金额以资鼓励,创造国内良好的开源环境
3)最后感谢兽兽及nutz社区广大网友的帮助和鼓励,没有您们的支持,这个项目不会历经6年多还在更新前进

PS:如有提问请新开帖~~~:)

11 回复

nutzwk 就差集成angularjs 就完美了

分布式事务如何保证一致性

6、开发注意事项一
1)有些表单内容提交不了,可能是包含了XSS跨站攻击或SQL关键词,您可以根据需要修改这些关键词,详见
https://github.com/Wizzercn/NutzWk/blob/nutzboot-dubbo/wk-app/wk-nb-web-platform/src/main/java/cn/wizzer/app/web/commons/processor/XssSqlFilterProcessor.java

2)系统全局变量也是通过动作链设置到request上下文的,比如 AppRoot、AppBase、lang、shiro等变量或工具类,详见
https://github.com/Wizzercn/NutzWk/blob/nutzboot-dubbo/wk-app/wk-nb-web-platform/src/main/java/cn/wizzer/app/web/commons/processor/GlobalsSettingProcessor.java

3、有人会问自定义路由,比如 /sysadmin 为什么等价于 /platform/login ,后台自定义路由管理的具体实现是什么,详见
https://github.com/Wizzercn/NutzWk/tree/nutzboot-dubbo/wk-app/wk-nb-web-platform/src/main/java/cn/wizzer/app/web/commons/filter

ps:其他问题等有人提问的时候更新到这里

微服务版本代码生成器 5.0.6 已经可以用了,IDEA插件在线搜索 wk-code-generator-nb 或按 wk-wiki 里教程进行安装、使用。

你好,NutzWk-NB版本5.0.7在centos7上无法启动。下面是NutzWk/wk-app/wk-nb-service-sys/路径下执行mvn compile nutzboot:run启动后的错误日志,请问是什么原因?

[WARN ] 16:05:13.088 com.alibaba.dubbo.registry.integration.RegistryProtocol$DestroyableExporter$1.run(RegistryProtocol.java:510) -  [DUBBO] sleep interrupted, dubbo version: 2.6.2, current host: 10.26.198.1
java.lang.InterruptedException: sleep interrupted
	at java.lang.Thread.sleep(Native Method)
	at com.alibaba.dubbo.registry.integration.RegistryProtocol$DestroyableExporter$1.run(RegistryProtocol.java:506)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
[INFO ] 16:05:13.088 com.alibaba.dubbo.registry.integration.RegistryProtocol$DestroyableExporter$1.run(RegistryProtocol.java:505) -  [DUBBO] Waiting 10000ms for registry to notify all consumers before unexport. Usually, this is called when you use dubbo API, dubbo version: 2.6.2, current host: 10.26.198.1
[INFO ] 16:05:23.089 com.alibaba.dubbo.registry.integration.RegistryProtocol$DestroyableExporter$1.run(RegistryProtocol.java:505) -  [DUBBO] Waiting 10000ms for registry to notify all consumers before unexport. Usually, this is called when you use dubbo API, dubbo version: 2.6.2, current host: 10.26.198.1
[WARNING] thread Thread[Abandoned connection cleanup thread,5,cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher] was interrupted but is still alive after waiting at least 15000msecs
[WARNING] thread Thread[Abandoned connection cleanup thread,5,cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher] will linger despite being asked to die via interruption
[WARNING] thread Thread[DubboRegistryFailedRetryTimer-thread-1,5,cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher] will linger despite being asked to die via interruption
[WARNING] thread Thread[DubboSaveRegistryCache-thread-1,5,cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher] will linger despite being asked to die via interruption
[WARNING] thread Thread[Exporter-Unexport-thread-1,5,cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher] will linger despite being asked to die via interruption
[WARNING] NOTE: 4 thread(s) did not finish despite being asked to  via interruption. This is not a problem with exec:java, it is a problem with the running code. Although not serious, it should be remedied.
[WARNING] Couldn't destroy threadgroup org.codehaus.mojo.exec.ExecJavaMojo$IsolatedThreadGroup[name=cn.wizzer.app.sys.commons.core.DubboRpcSysMainLauncher,maxpri=10]
java.lang.IllegalThreadStateException
    at java.lang.ThreadGroup.destroy (ThreadGroup.java:778)
    at org.codehaus.mojo.exec.ExecJavaMojo.execute (ExecJavaMojo.java:321)
    at org.nutz.boot.maven.RunMojo.execute (RunMojo.java:40)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 23.383 s
[INFO] Finished at: 2018-07-11T16:05:28+08:00
[INFO] ------------------------------------------------------------------------
[INFO ] 16:05:28.100 com.alibaba.dubbo.config.AbstractConfig$1.run(AbstractConfig.java:81) -  [DUBBO] Run shutdown hook now., dubbo version: 2.6.2, current host: 10.26.198.1


@michaelzqw 1、提问请发新帖;2、详细阅读wk-wiki;3、运行环境、完整日志内容请贴到新帖里。

5.0.7发布了,5.0.7 版更新内容如下:

add: API通过header参数做签名验证的方法;

add: 通过API上传文件示例代码;

add: 用户单一登录+踢人下线功能;

add: 后台站内信通知功能(websocket+浏览器通知);

add: 消息中心及消息管理功能;

add: BaseService类增加一些公共方法;

fixed: BaseService类getEntity()方法的bug;

fixed: jstree版本更新为3.3.5,解决了一个已知bug(加载ajax数据时,如果ajax数据为空则不能正常初始化的问题);

来自 iPhone 6

<div id="dialogAdd" class="modal fade bs-modal-sm" tabindex="-3" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
        </div>
    </div>
</div>

如果想让模态框里的JS每次都执行:

        $("#dialogAdd").on("hidden.bs.modal", function () {
            $(this).removeData("bs.modal");
            $(this).find(".modal-content").children().remove();//弹出的模态框数据没被清除可以加上这句话
        });

当出现父窗口里弹出子模态框的时候,需要判断是哪个窗口:

        $("#dialogAdd").on("hidden.bs.modal", function (e) {
            //判断事件触发对应的元素id
            if(e.target.id === "dialogAdd"){
                $(this).removeData("bs.modal");
                $(this).find(".modal-content").children().remove();
            }
        });

redis zookeeper 安装 运行教程 可以参考如下地址

https://my.oschina.net/wangyan9110/blog/911216
添加回复
请先登陆
回到顶部