Skip to content

Commit c68dfc0

Browse files
authored
Merge pull request boylegu#34 from boylegu/issue/33/readme_cn
close boylegu#33 add readme_cn.md
2 parents d807606 + 0c38909 commit c68dfc0

File tree

2 files changed

+275
-6
lines changed

2 files changed

+275
-6
lines changed

README-CN.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
## SprintBoot-Vue
2+
3+
SpringBoot + 前端MVVM 基于Java的微服务全栈快速开发实践
4+
5+
<p align="center">
6+
<a href ="##"><img alt="spring_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/newlogo.jpg?raw=true"></a></p>
7+
8+
<h4 align="center" style="color: #3399FF">
9+
Convenient & efficient and better performance for Java microservice full stack.
10+
</h4>
11+
12+
<p align="center" style="color: #FF66FF">Commemorate the 6 anniversary of enter the profession.</p>
13+
14+
<p align="center" style="color: #FF9933">Give beginner as a present.</p>
15+
16+
<p align="right" style="color: #3399FF">———————By Boyle Gu</p>
17+
18+
## 背景
19+
如今Web开发领域,当有人提到Java时,总会让人觉得臃肿、古老而过时且开发效率没有某些动态语言高效,甚至在此之前还有人高喊“Java 已死!”,但是事实真是如此吗?其实如果你一直关注着Java,那你的感悟会更深,尽管它有很多的缺点和啰嗦,但不可否认,Java依然是工业界中最优秀的语言,而且它一直保持着与时俱进。本项目将使用SpringBoot + Vue2 + Webpack2 配合最简单CRUD的逻辑来展示一个基于Java的微服务全栈快速开发实践的Demo。
20+
21+
在某些时候,其开发效率已经并不比某些动态语言低。
22+
23+
## 为什么是SpringBoot
24+
25+
首先先来简单的介绍一下Spring,它是目前Java生态中最广为人知、流行的企业级Web框架。不像其他一些框架仅聚焦在某个领域,Spring框架通过其容器化组件式管理及开发,可提供或定制各式各样的功能来满足企业化需求。
26+
27+
那么相较于Spring,Spring Boot的目标是更加容易的创建Spring应用、建立自动化、最少人为干预的生产级配置,真正意义做到开箱即用,并且对于新用户及Spring平台的用户极易上手,快速开发。
28+
29+
下图主要展示了Spring Boot在Spring庞大的生态圈中的层级关系
30+
31+
<p align="center">
32+
<a href ="##"><img alt="spring_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/springboot.png?raw=true"></a></p>
33+
34+
SpringBoot的目标主要:
35+
36+
- 为所有Spring开发提供一个从根本上更快,且随处可得的入门体验。
37+
38+
- 开箱即用,但通过不采用默认设置可以快速摆脱这种方式。
39+
40+
- 提供一系列大型项目常用的非功能性特征,比如:内嵌服务器,安全,指标,健康检测,外部化配置。
41+
42+
**绝对没有代码生成,也不需要XML配置。**
43+
44+
下面展示的是本项目的SpringBoot相关代码片段,你觉得简单么?
45+
46+
~~~~java
47+
@RestController
48+
@RequestMapping("/api/persons")
49+
public class MainController {
50+
51+
@RequestMapping(
52+
value = "/detail/{id}",
53+
method = RequestMethod.GET,
54+
produces = MediaType.APPLICATION_JSON_VALUE
55+
)
56+
public ResponseEntity<Persons> getUserDetail(@PathVariable Long id) {
57+
58+
/*
59+
* @api {GET} /api/persons/detail/:id details info
60+
* @apiName GetPersonDetails
61+
* @apiGroup Info Manage
62+
* @apiVersion 1.0.0
63+
*
64+
* @apiExample {httpie} Example usage:
65+
*
66+
* http GET http://127.0.0.1:8000/api/persons/detail/1
67+
*
68+
* @apiSuccess {String} email
69+
* @apiSuccess {String} id
70+
* @apiSuccess {String} phone
71+
* @apiSuccess {String} sex
72+
* @apiSuccess {String} username
73+
* @apiSuccess {String} zone
74+
*/
75+
76+
Persons user = personsRepository.findById(id);
77+
78+
return new ResponseEntity<>(user, HttpStatus.OK);
79+
}
80+
81+
}
82+
~~~~
83+
84+
### 为什么是MVVM
85+
86+
那么在我继续之前,我也想和大家回顾一下Web开发的发展简史:
87+
88+
- 第一阶段: 网页三剑客,生猛的通过原生javascript直接操作Dom树;
89+
90+
- 第二阶段: JQuery诞生,配合前端MVC为代表的Backbone.js, 让我们可以优雅而简单的操作Dom树;
91+
92+
- 第三阶段: 后端架构升级为MVC,前后端分工更清晰,前端工程化、ECMAScript规范开始崭露头角;
93+
94+
- 第四阶段: 后端架构进入了微服务时代,前端架构不仅升级为MVVM,ES6更是成为目前事实上的标准;
95+
96+
在这里,我不想过于神化MVVM有多么的先进,JQuery为代表的MVC有多么的落后,但确实MVVM有着很多先进的特性:
97+
98+
- 低开销
99+
100+
- 易维护
101+
102+
- 可重用
103+
104+
### 为什么选择Vue.js
105+
106+
Vue.js是MVVM设计模式中目前最火热的一个前端框架之一,除了性能表现优异之外,与类似React相比,更轻量级、更容易上手。
107+
108+
通过Vue中的“单文件组件”特性,更灵活的定义组件,不仅使代码结构更清晰,而且能与任何其他组件进行随意组合,更具复用性。
109+
110+
<p align="center">
111+
<a href ="##"><img style="box-shadow: 8px 8px 5px #888888;"alt="sanic_vue" src="http://i2.muimg.com/536217/5ae4b10becac44b0.png"></a>
112+
113+
### Webpack是什么
114+
Webpack提供了一整套前端工程自动化的解决方案
115+
116+
## Demo
117+
118+
一个简单的“上海人员信息查询系统”作为例子
119+
120+
121+
### 具备的功能(v0.1)
122+
123+
- Spring Boot (后端)
124+
125+
- 通过在Spring Boot中建立基于RestFul-API并使用`@ RequestMapping`实现一个基本的CRUD逻辑
126+
127+
- 处理CORS(跨域资源共享)
128+
129+
- 在Spring Boot中进行单元测试
130+
131+
- 支持热加载
132+
133+
- 增加api接口文档
134+
135+
- 通过SpringBoot配合JPA来实现RestFul-API的分页
136+
137+
- VueJS & webpack (前端)
138+
139+
- 遵循ECMAScript 6 规范
140+
141+
- 如何在vue中使用‘单文件组件’进行开发编码
142+
143+
- 演示‘非父子组件’如何进行简单的通信以及‘父子组件’之间如何传递数据
144+
145+
- 如何和后端进行数据交互
146+
147+
- 如何在vue中优雅的引入第三方JS库
148+
149+
- 格式化时间
150+
151+
- 分页实现
152+
153+
- 可复用组件
154+
155+
- DbHeader.vue
156+
- DbFooter.vue (sticky footer)
157+
- DbFilterinput.vue
158+
- DbModal.vue
159+
- DbSidebar.vue
160+
- DbTable.vue
161+
162+
>> 得益于类似vue、react等MVVM模式,本项目的任何组件,只要您觉得合适,都可以复用在您的任何项目中,避免重复造轮子。
163+
164+
- 如何通过webpack2配置来自动化构建前端环境(包括如何配置vue2、处理静态文件,构建不同环境等等)
165+
166+
### 本项目主要技术栈
167+
- Java 1.7
168+
- Spring Boot 1.5.x
169+
- Maven
170+
- sqlite (not recommend, only convenience example)
171+
- vueJS 2.x
172+
- webpack 2.x
173+
- element ui
174+
- axios
175+
176+
### 准备工作
177+
178+
- 安装JDK1.7或更新的版本
179+
- 安装Node.js/NPM
180+
181+
### 安装
182+
183+
- 编译前端开发环境
184+
185+
cd springboot_vue/frontend
186+
187+
npm install
188+
189+
### 使用
190+
191+
- 运行Spring Boot后端服务
192+
193+
cd springboot_vue/target/
194+
195+
java -jar springboot_vue-0.0.1-SNAPSHOT.jar
196+
197+
198+
[![](https://github.com/boylegu/SpringBoot-vue/blob/master/images/spring_run.png?raw=true)]()
199+
200+
- 运行前端服务
201+
202+
cd springboot_vue/frontend
203+
204+
npm run dev
205+
206+
207+
> 你也可以在生产环境中运行`cd sanic_crudvue/frontend;npm run build`进行编译并配合Nginx
208+
209+
## 未来计划
210+
211+
本项目可以作为工作参考、学习或者教学演示,之后将陆续以版本的形式,即每个版本都会新增不同的功能演示项,不定期进行发布更新,有以下功能已经在计划之中:
212+
213+
1. 用户认证
214+
2. 引入更高级的vuex组件通信机制
215+
3. 演示vue-route的使用
216+
4. 加入docker部署环境
217+
5. 新增针对yarn的支持
218+
... ...
219+
220+
## 技术、教学支持
221+
222+
由于个人时间暂时有限,关于Sanic、Vue、webpack等所有的核心的议题内容非常庞大,因此我将以以下形式来回答和解释关于本项目Demo问题:
223+
224+
1. 以Github Issue的形式进行提问
225+
2. 电子邮件的形式 [email protected]
226+
3. QQ群:315308272
227+
228+
## My Final Thoughts
229+
230+
```
231+
. ____ _
232+
/\\ / ___'_ __ _ _(_)_ __ __ _
233+
( ( )\___ | '_ | '_| | '_ \/ _` |
234+
\\/ ___)| |_)| | | | | || (_| |
235+
' |____| .__|_| |_|_| |_\__, |
236+
\ ===========|_|==============|___/== ▀
237+
\- ▌ SpringBoot-vue ▀
238+
- ▌ (o) ▀
239+
/- ▌ Go Go Go ! ▀
240+
/ =================================== ▀
241+
██
242+
243+
244+
```
245+

README.md

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77

88
<p align="center">
9-
<a href ="##"><img alt="spring_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/newlogo.jpg?raw=true"></a>
9+
<a href ="##"><img alt="spring_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/newlogo.jpg?raw=true"></a></p>
1010

1111
<h4 align="center" style="color: #3399FF">
1212
Convenient & efficient and better performance for Java microservice full stack.
@@ -21,7 +21,7 @@ Convenient & efficient and better performance for Java microservice full stack.
2121

2222
## overview
2323

24-
This‘s a CRUD demo example base Spring Boot with Vue2 + webpack2. I hope pass thought this project for express Java microservice full stack base web practice.
24+
Now about Web develop fields. It's very bloated, outmoded and some development efficiency have a lower with each other than other dynamic language when people refers to Java. Even before somebody shouts loudly ‘Java was died’. But is this really the case? In fact, If you often attention to Java in long time, your feel is too deep. Though it's many disadvantages and verbose. It couldn't be denied that Java is still best language in industry member, and advance with the times. This project is a CRUD demo example base Spring Boot with Vue2 + webpack2. I hope pass thought this project for express Java microservice fast full stack base web practice.
2525

2626
## Why Spring Boot
2727

@@ -30,8 +30,10 @@ Spring is a very popular Java-based framework for building web and enterprise ap
3030
In relation to Spring,
3131
Spring Boot aims to make it easy to create Spring-powered, production-grade applications and services with minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need.
3232

33-
The diagram below shows Spring Boot as a point of focus on the larger Spring ecosystem. It presents a small surface area for users to approach and extract value from the rest of Spring:
33+
The diagram below shows Spring Boot as a point of focus on the larger Spring ecosystem:
3434

35+
<p align="center">
36+
<a href ="##"><img alt="spring_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/springboot.png?raw=true"></a></p>
3537

3638
The primary goals of Spring Boot are:
3739

@@ -189,10 +191,9 @@ This's a sample ShangHai people information system as example demo.
189191
- Run back-end server
190192

191193
cd springboot_vue/target/
192-
194+
193195
java -jar springboot_vue-0.0.1-SNAPSHOT.jar
194196

195-
196197
[![](https://github.com/boylegu/SpringBoot-vue/blob/master/images/spring_run.png?raw=true)]()
197198

198199
- Run Front-end Web Page
@@ -201,9 +202,32 @@ This's a sample ShangHai people information system as example demo.
201202

202203
npm run dev
203204

204-
205205
> You can also run `cd springboot_vue/frontend;npm run build` and it's with Nginx in the production environment
206206
207+
208+
## Future Plan
209+
210+
This project can be reference,study or teaching demonstration. After, I will update at every increme version in succession. In future,I have already some plan to below:
211+
212+
1. User Authentication
213+
2. state manage with vuex
214+
3. use vue-route
215+
4. add docker deploy method
216+
5. support yarn
217+
... ...
218+
219+
## Support
220+
221+
1. Github Issue
222+
223+
2. To e-mail: [email protected]
224+
225+
3. You can also join to QQ Group: 315308272
226+
227+
## Related projects
228+
229+
- [Sanic-Vue for Python](https://github.com/boylegu/SanicCRUD-vue)
230+
207231
## My Final Thoughts
208232

209233
```

0 commit comments

Comments
 (0)