是五月呀!


  • 首页

  • 分类

  • 归档

  • 标签

  • 关于
是五月呀!

maven指定java版本

发表于 2018-11-09 | 分类于 maven | 字数统计: 208(字) | 阅读时长: 1(分)

如果使用Spring Boot搭建项目,可以指定property:

1
2
3
<properties>
<java.version>1.8</java.version>
</properties>

注意java.version这个参数并不是maven提供的,而是Spring Boot特有的。

阅读全文 »
是五月呀!

安装JDK

发表于 2018-11-09 | 分类于 java | 字数统计: 160(字) | 阅读时长: 1(分)

以安装jdk1.8为例,其他版本类似。

首先找到官网下载页面
找到对应的版本,右键 复制链接地址,http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
然后到服务器指定目录下输入命令:

1
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz

阅读全文 »
是五月呀!

Spring AOP类内部方法调用不拦截

发表于 2018-11-08 | 分类于 spring , java | 字数统计: 704(字) | 阅读时长: 3(分)

使用Spring AOP过程中,可能遇到过下列奇怪问题:

  • 类内部方法间调用AOP不起作用
  • 类内部方法间调用事务不起作用
  • 内部类异步线程调用外层方法事务不起作用

由于Spring的事务底层也是用AOP实现的,因此,这些症状都可以归结为,类内部方法间调用AOP失效。

阅读全文 »
是五月呀!

Filter实现返回结果AES加密

发表于 2018-11-07 | 分类于 spring , java | 字数统计: 2,408(字) | 阅读时长: 12(分)

场景:
对于新版本(版本信息在请求header中)接口,使用AES算法对返回结果进行全局加密。
原始接口都是RESTful类型,使用@ResponseBody标注,返回json数据。

考虑实现方案:

  • web容器过滤器Filter
  • Spring拦截器Interceptor
  • Spring的HttpMessageConverter
  • Spring的ResponseBodyAdvice
阅读全文 »
是五月呀!

IDEA插件开发(十二)mybatis插件之alias解析

发表于 2018-11-01 | 分类于 idea , java | 字数统计: 12(字) | 阅读时长: 1(分)

今天主要介绍resultType和parameterType中的alias解析。

是五月呀!

IDEA插件开发(十一)mybatis插件之Xml校验

发表于 2018-10-26 | 分类于 idea , java | 字数统计: 621(字) | 阅读时长: 3(分)

今天要实现的功能是,检查xml中的增删改查有没有对应的DAO层方法,如果没有,则报错。

IDEA插件中是通过 Inspection 来实现这个功能。

对XML的检查,IDEA提供了一个BasicDomElementsInspection来做基本检查,我们需要做的就是做好DOM解析工作,对关键属性添加converter。最后注册到plugin.xml即可。

阅读全文 »
是五月呀!

IDEA插件开发(十)mybatis插件之DAO与XML之间跳转

发表于 2018-10-26 | 分类于 idea , java | 字数统计: 658(字) | 阅读时长: 3(分)

使用Mybatis进行开发时,还有一个常用场景是从DAO层方法跳转到XML标签,或者反过来从XML标签跳转到DAO层方法。
可以使用lineMarkerProvider来实现该功能。

Line markers help to annotate any code with icons on the gutter. These icons may provide navigation to related code.

阅读全文 »
是五月呀!

IDEA插件开发(九)mybatis插件之参数补全

发表于 2018-10-25 | 分类于 idea , java | 字数统计: 805(字) | 阅读时长: 4(分)

IDEA插件开发时,可以有两种途径提供代码补全:

  • 实现Reference的getVariants()方法,返回一个数组,类型为String或者PsiElement或者LookupElement。这种方式只支持基本(basic)补全操作。
  • 继承CompletionContributor,支持basic、smart和class name三种补全方式。

本文主要介绍继承CompletionContributor的方式。

阅读全文 »
是五月呀!

IDEA插件开发(八)mybatis插件之参数引用

发表于 2018-10-24 | 分类于 idea , java | 字数统计: 2,118(字) | 阅读时长: 9(分)

IDEA插件开发(七)mybatis插件之mapper解析 一文中使用到了PropertyConverter来为property属性添加引用,实现鼠标点击跳转,代码补全提示等功能,其中使用了ContextPsiFieldReference,它继承了PsiReferenceBase,实现resolve()方法来返回对应的引用对象。

今天主要就说说引用( PSI References ),以及如何单独注册引用。

A reference in a PSI tree is an object that represents a link from a usage of a certain element in the code to the corresponding declaration. Resolving a reference means locating the declaration to which a specific usage refers.

Resolving references gives users the ability to navigate from a PSI element usage (accessing a variable, calling a method and so on) to the declaration of that element (the variable’s definition, a method declaration and so on). This feature is needed in order to support the Go to Declaration action invoked by Ctrl-B and Ctrl-Click, and it is a prerequisite for implementing the Find Usages action, the Rename refactoring and code completion.

举个例子,也就是我想要实现的效果。
Dao层有个方法:

1
List<User> findByUserName(@Param("userName") String userName);

然后对应的mapper文件中的查询语句:

1
2
3
4
5
6
7
8
9
<select id="findByUserName" resultType="com.damon4u.demo.domain.User">
select id, user_name
from user
<where>
<if test="userName != null">
user_name like CONCAT('%',#{userName},'%')
</if>
</where>
</select>

我现在想实现点击#{userName}中的userName能够跳转到Dao层方法的userName参数,即为xml中的参数添加引用。

阅读全文 »
是五月呀!

Charles抓取HTTPS接口

发表于 2018-10-22 | 分类于 http | 字数统计: 345(字) | 阅读时长: 1(分)

日常开发过程中,可能会需要抓取线上https的接口,这里介绍使用 Charles 来实现。

阅读全文 »
1234…7
五月y

五月y

Hello 五月y!

67 日志
24 分类
20 标签
RSS
GitHub weibo zhihu
© 2017 - 2018 五月y
由 Hexo 强力驱动
主题 - NexT.Mist