Skip to content

Commit 9ebd223

Browse files
committed
ApiBoot 0.1.1.RELEASE 版本
0 parents  commit 9ebd223

File tree

64 files changed

+3968
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3968
-0
lines changed

.gitignore

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
.sts4-cache
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/nbbuild/
22+
/dist/
23+
/nbdist/
24+
/.nb-gradle/
25+
/build/
26+
27+
### VS Code ###
28+
.vscode/
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
/*
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
*/
19+
20+
import java.io.File;
21+
import java.io.FileInputStream;
22+
import java.io.FileOutputStream;
23+
import java.io.IOException;
24+
import java.net.URL;
25+
import java.nio.channels.Channels;
26+
import java.nio.channels.ReadableByteChannel;
27+
import java.util.Properties;
28+
29+
public class MavenWrapperDownloader {
30+
31+
/**
32+
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
33+
*/
34+
private static final String DEFAULT_DOWNLOAD_URL =
35+
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
36+
37+
/**
38+
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
39+
* use instead of the default one.
40+
*/
41+
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
42+
".mvn/wrapper/maven-wrapper.properties";
43+
44+
/**
45+
* Path where the maven-wrapper.jar will be saved to.
46+
*/
47+
private static final String MAVEN_WRAPPER_JAR_PATH =
48+
".mvn/wrapper/maven-wrapper.jar";
49+
50+
/**
51+
* Name of the property which should be used to override the default download url for the wrapper.
52+
*/
53+
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
54+
55+
public static void main(String args[]) {
56+
System.out.println("- Downloader started");
57+
File baseDirectory = new File(args[0]);
58+
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
59+
60+
// If the maven-wrapper.properties exists, read it and check if it contains a custom
61+
// wrapperUrl parameter.
62+
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
63+
String url = DEFAULT_DOWNLOAD_URL;
64+
if (mavenWrapperPropertyFile.exists()) {
65+
FileInputStream mavenWrapperPropertyFileInputStream = null;
66+
try {
67+
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
68+
Properties mavenWrapperProperties = new Properties();
69+
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
70+
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
71+
} catch (IOException e) {
72+
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
73+
} finally {
74+
try {
75+
if (mavenWrapperPropertyFileInputStream != null) {
76+
mavenWrapperPropertyFileInputStream.close();
77+
}
78+
} catch (IOException e) {
79+
// Ignore ...
80+
}
81+
}
82+
}
83+
System.out.println("- Downloading from: : " + url);
84+
85+
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
86+
if (!outputFile.getParentFile().exists()) {
87+
if (!outputFile.getParentFile().mkdirs()) {
88+
System.out.println(
89+
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
90+
}
91+
}
92+
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
93+
try {
94+
downloadFileFromURL(url, outputFile);
95+
System.out.println("Done");
96+
System.exit(0);
97+
} catch (Throwable e) {
98+
System.out.println("- Error downloading");
99+
e.printStackTrace();
100+
System.exit(1);
101+
}
102+
}
103+
104+
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
105+
URL website = new URL(urlString);
106+
ReadableByteChannel rbc;
107+
rbc = Channels.newChannel(website.openStream());
108+
FileOutputStream fos = new FileOutputStream(destination);
109+
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
110+
fos.close();
111+
rbc.close();
112+
}
113+
114+
}

.mvn/wrapper/maven-wrapper.jar

47.2 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip

Integrated.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
暂无更新

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
2+
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://github.com/weibocom/motan/blob/master/LICENSE) ![](https://img.shields.io/badge/JDK-1.8+-green.svg) ![](https://img.shields.io/badge/SpringBoot-1.4+_1.5+_2.0+-green.svg)
3+
4+
`ApiBoot`是一款基于`SpringBoot2.x`的接口服务集成基础框架,内部提供了框架的封装集成,让接口开发者完成开箱即用,不再为搭建接口框架而犯愁,从而极大的提高开发效率。
5+
通过在我的`SpringBoot`系列教程中得到的学习者的反馈,才决定来封装一套对应我文章的基础框架,`ApiBoot`内的每一个框架的具体讲解都在文章内进行了详细说明,如果有不明白的可以通过如下途径访问我的文章:
6+
7+
- [我的博客 - 恒宇少年De成长之路](http://blog.yuqiyu.com)
8+
- [我的简书](https://www.jianshu.com/u/092df3f77bca)
9+
10+
## 主要功能
11+
12+
- **服务资源安全** :通过整合`SpringSecurity` + `Oauth2`来完成接口服务的安全性,安全拦截路径内的请求必须携带`请求令牌`才可以访问到资源内容,资源内容可配置指定身份、权限访问。
13+
- **服务授权认证中心**:服务授权以及认证是由`Oauth2`来担任,通过`password`授权模式获取`请求令牌`后访问资源服务,一个配置即可开启`Jwt`格式化`AccessToken`
14+
- **文档自动生成**:通过集成`Swagger2`来完成文档的侵入式生成,侵入式文档后期会被替代,`ApiBoot Security Oauth`已默认排除`swagger2`相关的资源路径。
15+
- **返回JSON格式化**:使用阿里巴巴的`FastJson`来完成返回`Json`字符串的格式化,自动扫描装载自定义的`ValueFilter`实现类,用于自定义返回格式化。
16+
- **数据库ORM框架**`mybatis-enhance`是一款由我开源的数据库持久化框架,基于`mybatis`进行封装编写,可以完成动态查询数据,语法与`SQL`语法几乎一致,内置常用方法提供直接调用,支持方法命名规则查询,一个接口方法就可以自动完成查询,不再编写`SQL`语句。
17+
- **自动分页插件**`mybatis-pageable`是一款由我开源的自动化分页插件,直接摆脱编写`分页代码`,仅仅需要传递的分页参数就可以自动进行查询,目前支持主流的**12**种数据库。
18+
- **代码生成插件**`code-builder`是一款由我开源的代码生成插件,直接拜托实体类的生成,支持自定义`freemarker`模板来完成自定义生成类文件,比如:`Service``Controller``Mapper`等。
19+
- **七牛云资源处理**:集成七牛云提供的SDK来完成文件的上传、下载等方法实现,开箱即用。
20+
- **阿里云OSS资源处理**:集成阿里云OSS提供的SDK来完成文件的上传、下载等方法实现,开箱即用。
21+
- **阿里云短信**:集成阿里云提供的SMS服务,简单配置即可完成短信发送,覆盖全球的短信服务,友好、高效、智能的互联化通讯能力,帮助企业迅速搭建客户触达通道。
22+
23+
更多功能请参考 [更多功能列表](https://github.com/hengboy/api-boot/Integrated.md)
24+
25+
## 组件
26+
27+
- **[Spring Security](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/)**:Spring提供的安全框架,Spring家族式的设计,无缝整合SpringBoot
28+
- **[OAuth2](https://oauth.net/2/)**:OAuth是一个网络授权的标准。
29+
- **[JWT](https://jwt.io/)**:JSON Web Token是目前流行的跨域认证解决方案,用于格式化OAuth2生成的Token。
30+
- **[Swagger2](https://swagger.io/)**:Swagger是一款API文档生成工具,自动扫描代码进行生成可运行测试的文档。
31+
- **[Mybatis Enhance](https://github.com/hengboy/mybatis-enhance)**`Enhance`是对于原生的`MyBatis`的增强编写,不影响任何原生的使用,使用后完全替代`mybatis-core``mybatis-spring`以及`mybatis-spring-boot-starter`,可以使用`SpringBoot`配置文件的形式进行配置相关的内容,尽可能强大的方便快速的集成`MyBatis`
32+
- **[Mybatis Pageable](https://github.com/hengboy/mybatis-pageable)**`MyBatis-Pageable`是一款自动化分页的插件,基于`MyBatis`内部的插件`Interceptor`拦截器编写完成,拦截`Executor.query`的两个重载方法计算出分页的信息以及根据配置的数据库`Dialect`自动执行不同的查询语句完成总数量的统计。
33+
- **[Code Builder](https://github.com/hengboy/code-builder)**`code-builder`是一款代码生成`maven mojo`插件,通过简单的配置就可以完成数据库内`Table`转换`Entity`或者其他实体类,想怎么生成完全根据你的个人业务逻辑,`code-builder`尽可能的完善的提供数据库内的一些定义的信息,让你更方便更灵活的来生成`Java`文件。
34+
35+
更多组件请参考[更多集成组件](https://github.com/hengboy/api-boot/Integrated.md)
36+
37+
## 怎么使用?
38+
39+
### 添加版本依赖
40+
41+
在使用`ApiBoot`时需要再`pom.xml`文件内的`dependencyManagement`标签内添加如下配置:
42+
43+
```xml
44+
<dependencyManagement>
45+
<dependencies>
46+
<dependency>
47+
<groupId>org.minbox.framework</groupId>
48+
<artifactId>api-boot-dependencies</artifactId>
49+
<version>0.1.1.RELEASE</version>
50+
<type>pom</type>
51+
<scope>import</scope>
52+
</dependency>
53+
</dependencies>
54+
</dependencyManagement>
55+
```
56+
57+
由于`ApiBoot`内后期规划集成的内容比较多,所以根据了`SpringBoot`的版本规划来进行了管理维护,这样在添加使用`ApiBoot`的依赖时就不再需要添加`版本号`,统一交由`api-boot-dependencies`进行管理。
58+
59+
> 注意:该版本默认添加了`spring-boot-dependencies`依赖。
60+
61+
## 使用Demo
62+
63+
`ApiBoot`会为每一个依赖提供一个演示代码集成子项目,都在`api-boot-samples`项目下,为了更好地解释`ApiBoot`的每一个依赖功能,恒宇少年会在每一个`sample`下添加当前项目的`readme`进行详细介绍。
64+
65+
Demo列表:
66+
67+
- [ApiBoot Security Oauth](https://github.com/hengboy/api-boot/api-boot-samples/api-boot-sample-security-oauth-jwt/README.md)
68+
- [ApiBoot Swagger](https://github.com/hengboy/api-boot/api-boot-samples/api-boot-sample-swagger/README.md)
69+
- [ApiBoot Http Converter](https://github.com/hengboy/api-boot/api-boot-samples/api-boot-sample-http-converter/README.md)
70+
71+
## 版本管理规范
72+
73+
项目的版本号格式为 x.x.x 的形式,其中 x 的数值类型为数字,从 0 开始取值,且不限于 0~9 这个范围。
74+
75+
项目目前处于在集成第三方框架阶段,第一位版本号统一使用0,如:0.x.x。
76+
77+
第三方框架集成阶段,版本升级如下所示:
78+
79+
- 小版本升级会增加第三位版本号的数值,如:0.1.0的小版本升级为:0.1.1。
80+
81+
- 大版本升级会增加第二位版本号的数值,如:0.1.0的大版本升级为:0.2.0。
82+
83+
## 开源交流
84+
85+
### 社区交流
86+
87+
#### 恒宇少年邮件
88+
89+
[jnyuqy@gmail.com](mailto:jnyuqy@gmail.com)
90+
91+
#### 恒宇少年微信
92+
93+
yuqiyu999
94+
95+
#### 钉钉群
96+
97+
![](https://github.com/hengboy/api-boot/dingding_group.JPG)
98+
99+
### 目录概述
100+
101+
```
102+
. framework
103+
├── converter
104+
├── enums
105+
├── event
106+
├── model
107+
├── security
108+
│ ├── delegate
109+
│ ├── jdbc
110+
│ ├── properties
111+
│ └── userdetails
112+
└── tools
113+
```
114+
115+
`ApiBoot`集成框架相关的代码实现都在`org.minbox.framework.api.boot.framework`目录下,如果你需要编写自己的业务尽可能的在`framework`的同级目录创建`package`来进行编写,`ApiBoot`默认扫描`org.minbox.framework.api.boot`目录下的所有类。
116+
117+
### 开源许可
118+
119+
`ApiBoot`采用`Apache2`开源许可。
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>api-boot-parent</artifactId>
7+
<groupId>org.minbox.framework</groupId>
8+
<version>0.1.1.RELEASE</version>
9+
<relativePath>../api-boot-parent</relativePath>
10+
</parent>
11+
<modelVersion>4.0.0</modelVersion>
12+
<artifactId>api-boot-autoconfigure</artifactId>
13+
<properties>
14+
<main.basedir>${basedir}/../..</main.basedir>
15+
</properties>
16+
<dependencies>
17+
<!--自动生成配置信息-->
18+
<dependency>
19+
<groupId>org.springframework.boot</groupId>
20+
<artifactId>spring-boot-configuration-processor</artifactId>
21+
</dependency>
22+
<!--ApiBoot Common-->
23+
<dependency>
24+
<groupId>org.minbox.framework</groupId>
25+
<artifactId>api-boot-common</artifactId>
26+
</dependency>
27+
<!--lombok-->
28+
<dependency>
29+
<groupId>org.projectlombok</groupId>
30+
<artifactId>lombok</artifactId>
31+
</dependency>
32+
<!--fastjson-->
33+
<dependency>
34+
<groupId>com.alibaba</groupId>
35+
<artifactId>fastjson</artifactId>
36+
<optional>true</optional>
37+
</dependency>
38+
39+
<!--Swagger-->
40+
<dependency>
41+
<groupId>io.springfox</groupId>
42+
<artifactId>springfox-swagger-ui</artifactId>
43+
<optional>true</optional>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.springfox</groupId>
47+
<artifactId>springfox-swagger2</artifactId>
48+
<optional>true</optional>
49+
</dependency>
50+
<dependency>
51+
<groupId>io.springfox</groupId>
52+
<artifactId>springfox-bean-validators</artifactId>
53+
<optional>true</optional>
54+
</dependency>
55+
56+
<!--spring web-->
57+
<dependency>
58+
<groupId>org.springframework.boot</groupId>
59+
<artifactId>spring-boot-starter-web</artifactId>
60+
<optional>true</optional>
61+
</dependency>
62+
<!--spring boot security-->
63+
<dependency>
64+
<groupId>org.springframework.boot</groupId>
65+
<artifactId>spring-boot-starter-security</artifactId>
66+
<optional>true</optional>
67+
</dependency>
68+
<!--security oauth2-->
69+
<dependency>
70+
<groupId>org.springframework.security.oauth</groupId>
71+
<artifactId>spring-security-oauth2</artifactId>
72+
<optional>true</optional>
73+
</dependency>
74+
<!--jwt-->
75+
<dependency>
76+
<groupId>org.springframework.security</groupId>
77+
<artifactId>spring-security-jwt</artifactId>
78+
<optional>true</optional>
79+
</dependency>
80+
</dependencies>
81+
</project>

0 commit comments

Comments
 (0)