|  | 
|  | 1 | +[]() | 
|  | 2 | +[]() | 
|  | 3 | +[]() | 
|  | 4 | +[]() | 
|  | 5 | +[]() | 
|  | 6 | + | 
|  | 7 | + | 
|  | 8 | +<p align="center"> | 
|  | 9 | +  <a href ="##"><img alt="sanic_vue" src="https://github.com/boylegu/SpringBoot-vue/blob/master/images/newlogo.jpg?raw=true"></a> | 
|  | 10 | + | 
|  | 11 | +<h4 align="center" style="color:	#3399FF"> | 
|  | 12 | +Convenient & efficient and better performance for Java microservice full stack. | 
|  | 13 | +</h4> | 
|  | 14 | + | 
|  | 15 | +<p align="center" style="color: #FF66FF">Commemorate the 6 anniversary of enter the profession.</p> | 
|  | 16 | + | 
|  | 17 | +<p align="center" style="color: #FF9933">Give beginner as a present.</p> | 
|  | 18 | + | 
|  | 19 | +<p align="right" style="color: #3399FF">———————By Boyle Gu</p> | 
|  | 20 | + | 
|  | 21 | + | 
|  | 22 | +## overview | 
|  | 23 | + | 
|  | 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. | 
|  | 25 | + | 
|  | 26 | +## Why Spring Boot | 
|  | 27 | + | 
|  | 28 | +Spring is a very popular Java-based framework for building web and enterprise applications. Unlike many other frameworks, which focus on only one area, Spring framework provides a wide verity of features addressing the modern business needs via its portfolio projects. | 
|  | 29 | + | 
|  | 30 | +In relation to Spring,  | 
|  | 31 | +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. | 
|  | 32 | + | 
|  | 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: | 
|  | 34 | + | 
|  | 35 | + | 
|  | 36 | +The primary goals of Spring Boot are: | 
|  | 37 | + | 
|  | 38 | +- To provide a radically faster and widely accessible ‘getting started’ experience for all Spring development. | 
|  | 39 | + | 
|  | 40 | +- To be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults. | 
|  | 41 | + | 
|  | 42 | +- To provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration). | 
|  | 43 | + | 
|  | 44 | +**Spring Boot does not generate code and there is absolutely no requirement for XML configuration.** | 
|  | 45 | + | 
|  | 46 | +Below are this project code snippet. Do you think simple?  | 
|  | 47 | + | 
|  | 48 | +~~~~java | 
|  | 49 | +@RestController | 
|  | 50 | +@RequestMapping("/api/persons") | 
|  | 51 | +public class MainController { | 
|  | 52 | + | 
|  | 53 | +    @RequestMapping( | 
|  | 54 | +            value = "/detail/{id}",  | 
|  | 55 | +            method = RequestMethod.GET,  | 
|  | 56 | +            produces = MediaType.APPLICATION_JSON_VALUE | 
|  | 57 | +            ) | 
|  | 58 | +    public ResponseEntity<Persons> getUserDetail(@PathVariable Long id) { | 
|  | 59 | + | 
|  | 60 | +        /* | 
|  | 61 | +        *    @api {GET} /api/persons/detail/:id  details info | 
|  | 62 | +        *    @apiName GetPersonDetails | 
|  | 63 | +        *    @apiGroup Info Manage | 
|  | 64 | +        *    @apiVersion 1.0.0 | 
|  | 65 | +        * | 
|  | 66 | +        *    @apiExample {httpie} Example usage: | 
|  | 67 | +        * | 
|  | 68 | +        *        http GET http://127.0.0.1:8000/api/persons/detail/1 | 
|  | 69 | +        * | 
|  | 70 | +        *    @apiSuccess {String} email | 
|  | 71 | +        *    @apiSuccess {String} id | 
|  | 72 | +        *    @apiSuccess {String} phone | 
|  | 73 | +        *    @apiSuccess {String} sex | 
|  | 74 | +        *    @apiSuccess {String} username | 
|  | 75 | +        *    @apiSuccess {String} zone | 
|  | 76 | +        */ | 
|  | 77 | + | 
|  | 78 | +        Persons user = personsRepository.findById(id); | 
|  | 79 | + | 
|  | 80 | +        return new ResponseEntity<>(user, HttpStatus.OK); | 
|  | 81 | +    } | 
|  | 82 | + | 
|  | 83 | +} | 
|  | 84 | +~~~~ | 
|  | 85 | + | 
|  | 86 | +## Why MVVM | 
|  | 87 | + | 
|  | 88 | +Although it seems similar to MVC (except with a "view model" object in place of the controller), there's one major difference — the view owns the view model. Unlike a controller, a view model has no knowledge of the specific view that's using it. | 
|  | 89 | + | 
|  | 90 | +This seemingly minor change offers huge benefits: | 
|  | 91 | + | 
|  | 92 | +1. View models are testable. Since they don't need a view to do their work, presentation behavior can be tested without any UI automation or stubbing. | 
|  | 93 | + | 
|  | 94 | +2. View models can be used like models. If desired, view models can be copied or serialized just like a domain model. This can be used to quickly implement UI restoration and similar behaviors. | 
|  | 95 | + | 
|  | 96 | +3. View models are (mostly) platform-agnostic. Since the actual UI code lives in the view, well-designed view models can be used on the iPhone, iPad, and Mac, with only minor tweaking for each platform. | 
|  | 97 | + | 
|  | 98 | +4. Views and view controllers are simpler. Once the important logic is moved elsewhere, views and VCs become dumb UI objects. This makes them easier to understand and redesign. | 
|  | 99 | +In short, replacing MVC with MVVM can lead to more versatile and rigorous UI code. | 
|  | 100 | + | 
|  | 101 | +>  *In short, replacing MVC with MVVM can lead to more versatile and rigorous UI code.* | 
|  | 102 | +
 | 
|  | 103 | +## Why to choose Vue.js | 
|  | 104 | + | 
|  | 105 | +Vue.js is relatively new and is gaining lot of traction among the community of developers. VueJs works with MVVM design paradigm and has a very simple API. Vue is inspired by AngularJS, ReactiveJs and updates model and view via two way data binding. | 
|  | 106 | + | 
|  | 107 | +Components are one of the most powerful features of Vue. They help you extend basic HTML elements to encapsulate reusable code. At a high level, components are custom elements that Vue’s compiler attaches behavior to.  | 
|  | 108 | + | 
|  | 109 | +<p align="center"> | 
|  | 110 | +  <a href ="##"><img style="box-shadow: 8px 8px 5px #888888;"alt="sanic_vue" src="http://i2.muimg.com/536217/5ae4b10becac44b0.png"></a> | 
|  | 111 | +   | 
|  | 112 | +## What's Webpack | 
|  | 113 | + | 
|  | 114 | +Webpack is a powerful tool that bundles your app source code efficiently and loads that code from a server into a browser. It‘s excellent solution in frontend automation project. | 
|  | 115 | + | 
|  | 116 | +## Demo | 
|  | 117 | + | 
|  | 118 | + | 
|  | 119 | +This's a sample ShangHai people information system as example demo. | 
|  | 120 | + | 
|  | 121 | +### Feature (v0.1) | 
|  | 122 | +- Spring Boot (Back-end)  | 
|  | 123 | + | 
|  | 124 | +  - Build RestFul-API on SpringBoot with `@RequestMapping` and base CRUD logic implementation | 
|  | 125 | + | 
|  | 126 | +  - Handle CORS(Cross-origin resource sharing)  | 
|  | 127 | + | 
|  | 128 | +  - Unit test on SpringBoot | 
|  | 129 | + | 
|  | 130 | +  - Support hot reload | 
|  | 131 | + | 
|  | 132 | +  - Add interface documents about it's rest-api | 
|  | 133 | + | 
|  | 134 | +  - Pagination implementation of RestFul-API with JPA and SpringBoot | 
|  | 135 | + | 
|  | 136 | +- VueJS & webpack (front-end) | 
|  | 137 | + | 
|  | 138 | +  - Follow ECMAScript 6 | 
|  | 139 | + | 
|  | 140 | +  - What about coding by single file components in vueJS | 
|  | 141 | +   | 
|  | 142 | +  - Simple none parent-child communication and parent-child communication  | 
|  | 143 | + | 
|  | 144 | +  - Interworking is between data and back-end | 
|  | 145 | +   | 
|  | 146 | +  - How grace import third JS package in vue | 
|  | 147 | +   | 
|  | 148 | +  - Handle format datetime | 
|  | 149 | +   | 
|  | 150 | +  - Pagination implementation | 
|  | 151 | +   | 
|  | 152 | +  - Reusable components | 
|  | 153 | +   | 
|  | 154 | +     - DbHeader.vue | 
|  | 155 | +     - DbFooter.vue  (sticky footer)  | 
|  | 156 | +     - DbFilterinput.vue | 
|  | 157 | +     - DbModal.vue | 
|  | 158 | +     - DbSidebar.vue | 
|  | 159 | +     - DbTable.vue | 
|  | 160 | + | 
|  | 161 | +  - Config front-end env on webpack2 (include in vue2, handle static file, build different environment...... with webpack2) | 
|  | 162 | + | 
|  | 163 | +### Main technology stack | 
|  | 164 | + | 
|  | 165 | +- Java 1.7 | 
|  | 166 | +- Spring Boot 1.5.x | 
|  | 167 | +- Maven | 
|  | 168 | +- sqlite (not recommend, only convenience example) | 
|  | 169 | +- vueJS 2.x | 
|  | 170 | +- webpack 2.x | 
|  | 171 | +- element ui | 
|  | 172 | +- axios | 
|  | 173 | + | 
|  | 174 | +### Preparation | 
|  | 175 | + | 
|  | 176 | +- Please must install Java 1.7  or even higher version | 
|  | 177 | + | 
|  | 178 | + | 
|  | 179 | +## My Final Thoughts | 
|  | 180 | + | 
|  | 181 | +``` | 
|  | 182 | +      .   ____          _ | 
|  | 183 | +     /\\ / ___'_ __ _ _(_)_ __  __ _ | 
|  | 184 | +    ( ( )\___ | '_ | '_| | '_ \/ _` | | 
|  | 185 | +     \\/  ___)| |_)| | | | | || (_| | | 
|  | 186 | +      '  |____| .__|_| |_|_| |_\__, | | 
|  | 187 | +\  ===========|_|==============|___/== ▀ | 
|  | 188 | +\- ▌          SpringBoot-vue             ▀ | 
|  | 189 | + - ▌                            (o)        ▀ | 
|  | 190 | +/- ▌            Go Go Go !               ▀ | 
|  | 191 | +/  =================================== ▀ | 
|  | 192 | +                    ██ | 
|  | 193 | +
 | 
|  | 194 | +
 | 
|  | 195 | +``` | 
0 commit comments