Spring集成Swagger实现RESTful接口文档自动化的使用感受

Swagger – The World’s Most Popular Framework for APIs
Swagger是一套规范和完整的框架用于生成、描述、调用和可视化RESTful风格的Web服务

1.集成

* 添加依赖:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.mangofactory</groupId>
<artifactId>swagger-springmvc</artifactId>
<version>1.0.2</version>
</dependency>

Read More

Mac下php版本降级切换,php7-->php5.3

下午同事发来一php项目,使用的是php5.3,但本机安装的是php7 只能进行切换,大概记录下切换的过程,整个过程折腾了一个下午

1.使用brew

2.安装xcode-tools xcode-install –install

3.brew update

Read More

Maven fails to parse POMs at jenkins

在进行构建时出现以下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
Started by user anonymous
Building in workspace /Users/Melon/.jenkins/jobs/first/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://git.coding.net/melongit/jdbcCoreframework.git # timeout=10
Fetching upstream changes from https://git.coding.net/melongit/jdbcCoreframework.git
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username melongit # timeout=10
> git config --local credential.helper store --file=/Users/Melon/Documents/Tomcat7/temp/git2101628945155958281.credentials # timeout=10
> git -c core.askpass=true fetch --tags --progress https://git.coding.net/melongit/jdbcCoreframework.git +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 0bd218173e74065806712e4dd656c911fc1e26bf (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 0bd218173e74065806712e4dd656c911fc1e26bf
> git rev-list 0bd218173e74065806712e4dd656c911fc1e26bf # timeout=10
Parsing POMs
ERROR: Failed to parse POMs
hudson.maven.MavenEmbedderException: 1 problem was encountered while building the effective settings
[FATAL] Non-readable settings /Users/Melon/.m2: /Users/Melon/.m2 (Is a directory) @ /Users/Melon/.m2
at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:128)
at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:109)
at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:136)
at hudson.maven.MavenUtil.createEmbedder(MavenUtil.java:212)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1285)
at hudson.maven.MavenModuleSetBuild$PomParser.invoke(MavenModuleSetBuild.java:1088)
at hudson.FilePath.act(FilePath.java:991)
at hudson.FilePath.act(FilePath.java:969)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.parsePoms(MavenModuleSetBuild.java:950)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:677)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
at hudson.model.Run.execute(Run.java:1741)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.maven.MavenEmbedderException: 1 problem was encountered while building the effective settings
[FATAL] Non-readable settings /Users/Melon/.m2: /Users/Melon/.m2 (Is a directory) @ /Users/Melon/.m2
at hudson.maven.MavenEmbedder.getSettings(MavenEmbedder.java:261)
at hudson.maven.MavenEmbedder.buildMavenExecutionRequest(MavenEmbedder.java:157)
at hudson.maven.MavenEmbedder.<init>(MavenEmbedder.java:120)
... 14 more
Caused by: org.apache.maven.settings.building.SettingsBuildingException: 1 problem was encountered while building the effective settings
[FATAL] Non-readable settings /Users/Melon/.m2: /Users/Melon/.m2 (Is a directory) @ /Users/Melon/.m2
at org.apache.maven.settings.building.DefaultSettingsBuilder.build(DefaultSettingsBuilder.java:116)
at hudson.maven.MavenEmbedder.getSettings(MavenEmbedder.java:259)
... 16 more
Finished: FAILURE

Read More

Hibernate Validator

Hibernate Validator是JSR-303的一个实现。在FormBean里添加Hibernate Validator的注解,与定义一个校验类的做法相比。注解更加简洁、灵活。

注解说明

Bean Validation 中内置的 constraint

Read More

去除Spring @ResponseBody产生的大量Accept-Charset

Spring MVC使用@ResponseBody后会产生很大的响应头(Accept-Charset会达到4K+),原因在于默认情况下StringHttpMessageConverter.writeInternal()会将所有可用字符集回写到response响应头中:

Read More

Java集合使用Tips

1.数组转ArrayList

ArrayList<String> arrayList = new ArrayList<String>(Arrays.asList(arr));

Read More

CentOS 6.5 kernel至3.10

  1. rpm –import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org

Read More

自定义Maven Archetype来快速搭建自己的项目结构

自定义Maven Archetype主要是使用命令archetype:create-from-project来快速生成archetype

1.首先使用eclipse创建一个maven项目

比如选择org.apache.maven.archetypes:maven-archetype-webapp为原型,然后添加groupId和artifactId信息后点finish创建项目。

Read More

AES对Restful接口进行简单的数据校验之移动篇(iOS&Android)

随着Restful的普及,越来越多的项目开始使用这种形式来进行接口的编写。Restful本身是无状态的,所以我们要对接口进行一些安全的校验,这可以从两个维度来考虑这个问题,1.防止接口数据被恶意重刷造成资源和数据的浪费 2.对用户进行权限校验来防止数据被恶心篡改

1.首先来说第一种情况: (主要是防止重放攻击)

Read More

Shiro

Keywords:Subject、SecurityManager、Realm

依赖关系

    Read More