Make small but daily progress

Make small but daily progress

2016-11-08

1. Install the activiti-eclipse plugin

Name: Activiti BPMN 2.0 designer
Location: http://activiti.org/designer/update/
This is installed, but an error is reported. The error message is that there is a jar that cannot be downloaded. This jar is:
org.eclipse.graphiti_0.11.4.v20150701-1432.jar
The amazing thing is that eclipse can't access that link, but it can be downloaded from the browser. After downloading, put it in the plugins folder,
Install again, OK, done

 

2016-11-22

1. An error was reported when configuring shiro's configuration file, and the reason was found to be caused by the following line

<bean id="shiroSessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager"></bean>

Error message:

Cannot convert value of type [org.hibernate.impl.SessionFactoryImpl] to required type [org.apache.shiro.session.mgt.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found

The specific reason is because the system also uses id="sessionFactory" when configuring hibernate, which leads to conflicts, and it is OK to change its name.

 PS: It turns out that the above solution is not feasible. After modification, shiro works well, but hibernate can't get sessionFactory.

So I used the most stupid method, the following configuration:

Add a sessionFactory implementation <bean id="sessionFactoryShiro" class="org.apache.shiro.session.mgt.SimpleSessionFactory"></bean>

然后注入:<bean id="shiroSessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">

<property name="sessionDAO" ref="shiroSessionDAO"/>

<property name="sessionFactory" ref="sessionFactoryShiro"/>

</bean>

2016-11-23

1, or toss shiro, to do a function to kick out users

Before using Spring Secutity, there was a way to directly kick out the specified user, so I formed a solidified thinking, and I have been looking for a similar method in shiro.

But Shiro doesn't seem to provide it directly. After copying it online, I found a fairly reliable solution:

 a: Get all activeSessions through sessionDao, if the name is the same as the login name, put a label: session.setAttribute('kick out', TRUE)

 b: Write an interceptor, configure it in shiroFilter, and call the subject.logout() method to log out if the 'kick out' mark is found

 c: Configure the interceptor in b in shirofilter and use it in the url to be intercepted, such as: /**=forceout,authc where forceout is a custom interceptor

         网上搜一下ForceLogoutFilter,应该会有一堆结果

之前走了一个更弯的路,之前如果判断出用户名相同,我直接session.setTimeOut(0),将session设置为失效,貌似是好使的

但是,反复测试会发现,sessionDao还是能获取到之前的session(shiro可能不是这么判断session失效的)

2、继续折腾shiro,又出了一个幺蛾子:浏览器直接输入程序地址后,跳转到login界面的时候出现了JSESSION,就像这个样子:

http://127.0.0.1/xxxx/login.jsp;JSESSIONID=2ede9ebf-b0c0-48ac-b67a-044c3e841dde

登陆后,shiro认证失败,网上查了一下大概原因:应该是跟浏览器的cookies有关,其实更换一下struts2jar的版本就行了,太低的版本对这个支持不太好,但是我用的是公司的框架,TNND把SSH集合到一个jar了,不太好换,所以采用拦截器的方式解决

网上搜一下:DisableUrlSessionFilter ,应该会有还多转载的

2016-12-30

1、IDEA断点进不去

       除了网上一堆的关于增加JAVA_OPTS的,很有可能就是点击了下图的 “禁用断点”

 2、用惯SVN的人肯定会习惯于 * 号,but sorry ,idea没有,只能通过颜色的变化来区别是否进行了修改

         而且,默认是不级联的,什么意思呢,就是你改了文件A,A变色了,但是A所在的文件夹就跟没事人一样不变色

         如果想让他变,那么需要把 settings >> Version Control >> Show directories with changed descendants 前面的checkbox勾上

3、关于添加版本控制

         这点要吐槽一下,可能是我这里代理的问题,github就算设置了代理,一样上传不上去

         改用SVN,记着,安装客户端的时候一定记着安装svnshell,安装的时候,那个是默认关闭的

          或者,如果你喜欢,可以选择安装sliksvn

            而且,通过 VCS >> Import into version control >> share XXX 只share了一个目录

             上传代码也是上传不上去,慢的要死,需要注意的是,注意选对SVN的版本,现在IDEA默认给出3个选择:

                           1.6          1.7             1.8   我们单位的server比较老,选择的1.6

 2017-1-4

    SPRINGMVC 默认是会拦截所有请求的,所以,如果想让你的css  js  等静态文件正确显示,其中一种办法是在web.xml

   中为这些静态的文件指定默认拦截器,如下:

<servlet-mapping>
  <servlet-name>default</servlet-name>
  <url-pattern>*.css</url-pattern>
</servlet-mapping>

 2017-1-9 

    SPRINGMVC4 配置json返回 

<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
   <property name="messageConverters">
      <list>
         <ref bean="mappingJacksonHttpMessageConverter" />
      </list>
   </property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
   <property name="supportedMediaTypes">
      <list>
         <value>text/html;charset=UTF-8</value>
      </list>
   </property>
</bean>

    使用springmvc转换json的时候,它默认把我实体中的字段都设置成了小写,一个解决办法:

        在要转换的实体中使用@JsonProperty("pId")进行标注

 

2017-1-12

 今天要把基于hibernate的项目的数据库从mysql换为informix,方言什么的都换了,查数据库的时候还是报错,调试了一下发现执行

select 1 报错,这个是在hibernate中配置的,如下:

<property name="validationQuery" value="select 1"> </property>

informix应该换为:

<property name="validationQuery" value="select count(*) from systables"> </property>

以前用dbcp这个不是必须的,但是换为dbcp2之后,这个是必须项

 

2017-2-6

  activiti使用

  今天把activiti的流程整通了一次,并做一些总结:

   一、开发步骤

    1、首先画流程图,我使用的idea中文老有乱码,所以我就在eclipse的插件中画了

           a:参与者 在Main config中的Assignee中配置,可以写成变量${xxx}在启动流程或者完成当前task的时候指定

                 下面的是在完成当前task后指定,变量boss的值为aaas

            Map<String,Object> vs = new HashMap<String,Object>();

vs.put("boss","aaas");
processEngine.getTaskService().complete(task.getId(),vs);

          b:可以指定Listener   

                   listneter主要有三种,全局的、连线的、task级的,观察者模式

    2、部署

          新部署的不会覆盖老的部署,会产生最新的版本,新启动的流程都取最新的部署

          如果有一个流程是在老部署的基础上提交的,并且没有完成,那么它的后续操作一样会沿用老部署的

          Deployment deployment = processEngine.getRepositoryService().createDeployment()

        .name("helloactiviti入门1").addClasspathResource("activiti/diagrams/HelloWorld.bpmn")

        .addClasspathResource("activiti/diagrams/HelloWorld.png").deploy();  

    3、启动流程

           一次部署,多次启动,下面是一个指定参与者的

           Map<String,Object> vs = new HashMap<String,Object>();

vs.put("userId","admin");
RuntimeService runtimeService = processEngine.getRuntimeService();
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("bpmn文件中的id",vs);

  4、执行流程

         具体的流程

    二、应用到项目中的思路

     1、在录入新业务的时候,启动工作流实例,获取流程实例ID:ProcessInstanceId,并与业务ID进行绑定(新建一张业务关联表)

     2、根据当前登录用户的ID获取其待办任务

List<Task> tasks = processEngine.getTaskService().createTaskQuery().taskAssignee("用户ID").list();

     3、根据待办任务可以获取流程实例ID:ProcessInstanceId

task.getProcessInstanceId()

     4、根据3中的ID即可关联到业务ID,然后进行业务的复杂操作

 

 2017-2-6

quartz自动任务,启动的时候报错,但是能正常启动

2016-04-1914:00:37.281 [main] DEBUG o.s.s.a.ScheduledAnnotationBeanPostProcessor -Could not find default ScheduledExecutorService bean org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.scheduling.TaskScheduler] is defined

 需要增加如下配置:

<!-- executor线程池,含义和java.util.concurrent.Executor是一样的,pool-size的大小官方推荐为5~10 -->
<task:executor id="executor" pool-size="5" />
<!-- scheduler的pool-size是ScheduledExecutorService线程池,默认为1 -->
<task:scheduler id="scheduler" pool-size="5" />
<task:annotation-driven executor="executor" scheduler="scheduler" />

 2017-02-10

一、redis客户端输出中文,出现了\xe6\x89\x8b\xe7\xbb\xad\xe8\xb4\xb9 的16进制

     在启动客户端的时候增加参数 --raw即可

     ./redis-cli --raw

二、用spring-data-redis连接的时候,后台报错无法验证,没有其他明确的提示,要注意redis是否运行在protect mode下

     可以设置密码 config set requirepass xxxxx

 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326614674&siteId=291194637