进击zheng项目zheng-umps-server

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u014449653/article/details/78355849

打了几盘农药后,就升一颗心,赛季初水真深,心累。继续上一篇说的内容,进去server的模块,server模块的里面有个admin的模块,这部分基本是前端的内容,不做解释。按照工程上结构从上到下进行梳理吧。
1. Controller
但多多少少了解和使用过SpringMVC的都知道这是干嘛的, Controller 把各种用户的请求进行业务的处理,封装成Model,返回给对应的View,这就是MVC!通过看注解,我们可以看到,在安全上,这个项目主要用到了shiro。同时提供了Swagger2作为一个测试框架(方便后端的开发者进行测试使用,不太在乎的也可以用postman这个利器)。

1.1 shiro

其实我也有点虚,不是身体上的虚,是心虚,不敢去讲太多,因为,我也不是太懂。就把我看到和知道的写写。先不用看代码,先去找shiro的配置文件,这么多配置文件,呵呵,没找到,原来藏在了client的模块里面-applicationContext-shiro.xml.特别要注意和学习的地方其实看client模块我们应该就知道了(顺便背两个单词:Auth**entic**ation:身份验证 Auth**oriz**ation:授权)

http://jinnianshilongnian.iteye.com/blog/2018936/   shiro科普
http://www.sojson.com/shiro
1.1.1 filter

过滤器? 这里应该称之为拦截器吧?,主要是为了身份认证 anon:所有的人都可以访问,authc:需要认证 user:表示用户不一定已通过认证,只要曾被shiro记住过登录状态的用户就可以正常发起请求,比如rememberMe。

<property name="filters">
    <util:map>
        <entry key="authc" value-ref="upmsAuthenticationFilter"/>
    </util:map>
</property>
<property name="filterChainDefinitions">
    <value>
        /manage/** = upmsSessionForceLogout,authc
        /manage/index = user
        /druid/** = user
        /swagger-ui.html = user
        /resources/** = anon
        /** = anon
    </value>
</property>
1.1.2 listener

会话监听器,没什么可以讲的,可以参考:

http://jinnianshilongnian.iteye.com/blog/2028675
1.1.3 realm

安全管理器,这块主要是授权和验证。extends AuthorizingRealm 来重写doGetAuthorizationInfo(授权)和doGetAuthenticationInfo(认证)的方法。

1.1.4 session

主要是这块的session的存储使用了redis

1.2 swagger2

项目启动后输入ip:port/swagger-ui.html进行接口的测试使用,工具很好用的。注意:/swagger-ui.html = user

applicationContext-dubbo-consumer

消费服务中心中的服务

 <!-- 用户 -->
    <dubbo:reference id="upmsUserService" interface="com.zheng.upms.rpc.api.UpmsUserService" mock="true"/>

以上,基本的umps的就大概看完了,细节的地方和登录的地方验权的地方还是需要仔细点。基本上,一个菜鸟对这个框架的初步认识就差不多了,一下阶段就是仿写了,如法炮制一个类似的。
国际惯例,原项目地址:

https://github.com/shuzheng/zheng
展开阅读全文

Yong Zheng's Death

10-31

Problem DescriptionnSome Chinese emperors ended up with a mysterious death. Many historians like to do researches about this. For example, the 5th Qing dynasty emperor Yong Zheng's death is often argued among historians. Someone say that he was killed by the top assassin Lu Siniang whose family were almost wiped out by Yong Zheng. Someone say that Yong Zheng was poisoned to death because he liked to eat all kinds of Chinese medicines which were said to have the functions of prolonging human lives. Recently, a new document was discovered in Gu Gong(the Forbidden City). It is a secret document written by Yong Zheng's most trusted eunuch. It reads on the cover: "This document tells how Yong Zheng died. But I can't write this in plain text. Whether people will understand this is depend on Gods." Historians finally found out that there are totally n strings in the document making a set S = s1,s2,... sn. You can make some death ciphers from the set. A string is called a DEATH CIPHER if and only if it can be divide into two substrings u and v, and u and v are both a prefix of a string from S (Note that u and v can't be empty strings, and u and v can be prefixes of a same string or two different strings).nnWhen all DEATH CIPHERs are put together, a readable article revealing Yong Zheng's death will appear.nnPlease help historians to figure out the number of different death ciphers.n nnInputnThe input consists of no more than 20 test cases.nnFor each case, the first line contains an integer n(1 <= n <= 10000), indicating the number of strings in S.nnThe following n lines contain n strings, indicating the strings in S. Every string only consists of lower case letters and its length is between 1 and 30(inclusive). nnThe input ends by n = 0.n nnOutputnFor each test case, print a number denoting the number of death ciphers.n nnSample Inputn2nabnacn0n nnSample Outputn9 问答

zheng框架的运行错误

09-07

新人上岗,公司要用zheng框架,但是我的报错了。各位大神帮我解决下呗rn我就是运行的ZhengUpmsRpcServiceApplication这个文件,教学中也是这样的,但是我没成功,求指点rnException in thread "main" com.alibaba.dubbo.rpc.RpcException: Fail to start server(url: dubbo://192.168.1.105:20881/com.zheng.upms.rpc.api.UpmsSystemService?anyhost=true&application=zheng-upms-rpc-service&channel.readonly.sent=true&codec=dubbo&dubbo=2.5.3&heartbeat=60000&interface=com.zheng.upms.rpc.api.UpmsSystemService&methods=selectByExample,insertSelective,countByExample,selectByExampleForStartPage,updateByPrimaryKeySelective,selectByExampleWithBLOBs,insert,selectFirstByExampleWithBLOBs,selectByExampleForOffsetPage,selectByExampleWithBLOBsForOffsetPage,updateByExampleWithBLOBs,updateByPrimaryKeyWithBLOBs,updateByExample,selectByPrimaryKey,deleteByExample,updateByExampleSelective,initMapper,updateByPrimaryKey,deleteByPrimaryKeys,deleteByPrimaryKey,selectByExampleWithBLOBsForStartPage,selectFirstByExample&monitor=dubbo%3A%2F%2Fzkserver%3A2181%2Fcom.alibaba.dubbo.registry.RegistryService%3Fapplication%3Dzheng-upms-rpc-service%26dubbo%3D2.5.3%26pid%3D10728%26protocol%3Dregistry%26refer%3Ddubbo%253D2.5.3%2526interface%253Dcom.alibaba.dubbo.monitor.MonitorService%2526pid%253D10728%2526timestamp%253D1504773460618%26registry%3Dzookeeper%26timestamp%3D1504773460359&pid=10728&side=provider&timeout=10000&timestamp=1504773460400) Failed to bind NettyServer on /192.168.1.105:20881, cause: Failed to bind to: /0.0.0.0:20881rn at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:289)rn at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.openServer(DubboProtocol.java:266)rn at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.export(DubboProtocol.java:253)rn at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:55)rn at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:56)rn at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)rn at com.alibaba.dubbo.registry.integration.RegistryProtocol.doLocalExport(RegistryProtocol.java:153)rn at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:107)rn at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:53)rn at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:54)rn at com.alibaba.dubbo.rpc.Protocol$Adpative.export(Protocol$Adpative.java)rn at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:485)rn at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:281)rn at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:242)rn at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:143)rn at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:109)rn at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)rn at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)rn at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)rn at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)rn at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)rn at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)rn at com.zheng.upms.rpc.ZhengUpmsRpcServiceApplication.main(ZhengUpmsRpcServiceApplication.java:17)rnCaused by: com.alibaba.dubbo.remoting.RemotingException: Failed to bind NettyServer on /192.168.1.105:20881, cause: Failed to bind to: /0.0.0.0:20881rn at com.alibaba.dubbo.remoting.transport.AbstractServer.(AbstractServer.java:72)rn at com.alibaba.dubbo.remoting.transport.netty.NettyServer.(NettyServer.java:63)rn at com.alibaba.dubbo.remoting.transport.netty.NettyTransporter.bind(NettyTransporter.java:33)rn at com.alibaba.dubbo.remoting.Transporter$Adpative.bind(Transporter$Adpative.java)rn at com.alibaba.dubbo.remoting.Transporters.bind(Transporters.java:48)rn at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchanger.bind(HeaderExchanger.java:41)rn at com.alibaba.dubbo.remoting.exchange.Exchangers.bind(Exchangers.java:63)rn at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol.createServer(DubboProtocol.java:287)rn ... 24 morernCaused by: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:20881rn at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:303)rn at com.alibaba.dubbo.remoting.transport.netty.NettyServer.doOpen(NettyServer.java:94)rn at com.alibaba.dubbo.remoting.transport.AbstractServer.(AbstractServer.java:67)rn ... 31 morernCaused by: java.net.BindException: Address already in use: bindrn at sun.nio.ch.Net.bind0(Native Method)rn at sun.nio.ch.Net.bind(Net.java:433)rn at sun.nio.ch.Net.bind(Net.java:425)rn at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)rn at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)rn at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.bind(NioServerSocketPipelineSink.java:148)rn at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleServerSocket(NioServerSocketPipelineSink.java:100)rn at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:74)rn at org.jboss.netty.channel.Channels.bind(Channels.java:468)rn at org.jboss.netty.channel.AbstractChannel.bind(AbstractChannel.java:192)rn at org.jboss.netty.bootstrap.ServerBootstrap$Binder.channelOpen(ServerBootstrap.java:348)rn at org.jboss.netty.channel.Channels.fireChannelOpen(Channels.java:176)rn at org.jboss.netty.channel.socket.nio.NioServerSocketChannel.(NioServerSocketChannel.java:85)rn at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:142)rn at org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory.newChannel(NioServerSocketChannelFactory.java:90)rn at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:282)rn ... 33 more 论坛

没有更多推荐了,返回首页