# microservices-demo
Demo application to go with my [Microservices Blog](https://spring.io/blog/2015/07/14/microservices-with-spring) on the spring.io website. **WARNING:** Only maven build has been updated. Gradle build still to be done.
![Demo System Schematic](https://github.com/paulc4/microservices-demo/blob/master/mini-system.jpg)
Clone it and either load into your favorite IDE or use maven/gradle directly.
_Note for gradle users:_ to make the intructions below build-tool independent, the gradle build copies its artifacts from `build/libs` to `target`.
## Versions
Current version (June 2018) v2.0.0 corresponds to Spring Boot 2 and Finchly release train.
**WARNING:** Only maven build has been updated. Gradle build still to be done.
Previous versions have been tagged and can be accessed using the `Branch` button above or using `git checkout <version>` - for example `git checkout v1.2.0`.
Tagged versions are:
* v2.0.0 - Spring Boot 2.0 and Spring Cloud release-train Finchley
* v1.2.0 corresponds to Spring Boot 1.5 and Spring Cloud release-train Edgeware
* v1.1.0 corresponds to Spring Cloud release-train Brixton
* v1.0.0 corresponds to Spring Cloud release-train Angel.SR6
## Using an IDE
You can run the system in your IDE by running the three server classes in order: _RegistrationService_, _AccountsService_ and _WebService_. Each is a Spring Boot application using embedded Tomcat. In Spring Tool Suite use `Run As ... Spring Boot App` otherwise just run each as a Java application - each has a static `main()` entry point.
As discussed in the Blog, open the Eureka dashboard [http://localhost:1111](http://localhost:1111) in your browser to see that the `ACCOUNTS-SERVICE` and `WEB-SERVICE` applications have registered. Next open the Demo Home Page [http://localhost:3333](http://localhost:3333) in and click one of the demo links.
The `localhost:3333` web-site is being handled by a Spring MVC Controller in the _WebService_ application, but you should also see logging output from _AccountsService_ showing requests for Account data.
## Command Line
You may find it easier to view the different applications by running them from a command line since you can place the three windows side-by-side and watch their log output
For convenience we are building a 'fat' executble jar whose start-class (main method entry-point) is defined to be in the class `io.pivotal.microservices.services.Main`. This application expects a single command-line argument that tells it to run as any of our three servers.
```
java -jar target/microservices-demo-2.0.0.RELEASE.jar registration|accounts|web
```
### Priocedure
To run the microservices system from the command-line, open three CMD windows (Windows) or three Terminal windows (MacOS, Linux) and arrange so you can view them conveniently.
1. In each window, change to the directory where you cloned the demo.
1. In the first window, build the application using either `mvn clean package` or `gradle clean assemble`. Either way the
generated file will be `target/microservices-demo-2.0.0.RELEASE.jar` (even if you used gradle).
1. In the same window run: `java -jar target/microservices-demo-2.0.0.RELEASE.jar registration`
1. Switch to the second window and run: `java -jar target/microservices-demo-2.0.0.RELEASE.jar accounts`
1. In the third window run: `java -jar target/microservices-demo-2.0.0.RELEASE.jar web`
1. In your favorite browser open the same two links: [http://localhost:1111](http://localhost:1111) and [http://localhost:3333](http://localhost:3333)
You should see servers being registered in the log output of the first (registration) window.
As you interact wiht the Web application, you should logging in the both the second and third windows.
For a list of valid accounts refer to the [data.sql](https://github.com/paulc4/microservices-demo/blob/master/src/main/resources/testdb/data.sql) that is used by the Account Service to set them up.
1. In a new window, run up a second account-server using HTTP port 2223:
* `java -jar target/microservices-demo-2.0.0.RELEASE.jar accounts 2223`
1. Allow it to register itself
1. Kill the first account-server and see the web-server switch to using the new account-server - no loss of service.
没有合适的资源?快使用搜索试试~ 我知道了~
Spring构建微服务实例(Spring、Spring Boot和Spring Cloud),Maven项目
共56个文件
java:18个
html:12个
png:6个
需积分: 2 46 下载量 187 浏览量
2019-06-10
11:29:11
上传
评论 1
收藏 3MB ZIP 举报
温馨提示
通过一个使用Spring、Spring Boot和Spring Cloud的小例子来说明如何构建微服务系统。 具体请看附件文件中的:readme.txt 和 [译]Spring构建微服务.png 访问地址:http://localhost:1111/ 运行顺序:RegistrationServer(服务注册)、AccountsServer(创建微服务)、WebServer(访问微服务) 最后,通过: http://localhost:3333/ 访问微服务 以上,演示了一个简单的web应用程序来访问账户数据。 所有的账户信息是通过RESTful接口获取账户microservice。
资源推荐
资源详情
资源评论
收起资源包目录
microservices-demo-master.zip (56个子文件)
[译]Spring构建微服务.png 2.47MB
readme.txt 76B
microservices-demo-master
.gitignore 406B
beans-vs-processes.jpg 89KB
.springBeans 1KB
build.gradle 1KB
src
main
resources
accounts-server.yml 2KB
testdb
data.sql 2KB
schema.sql 283B
web-server.yml 1KB
public
extlink.png 1KB
spring-trans.png 40KB
pws-header-logo_new.png 4KB
pivotal-logo-600.png 12KB
styles.css 563B
web-server
templates
empty.html 282B
header.html 3KB
error.html 2KB
accountSearch.html 2KB
index.html 2KB
account.html 713B
footer.html 609B
accounts.html 1KB
logback.xml 893B
db-config.properties 514B
account-controller-tests.properties 220B
accounts-server
templates
header.html 3KB
error.html 2KB
index.html 1KB
footer.html 594B
registration-server.yml 722B
java
io
pivotal
microservices
exceptions
AccountNotFoundException.java 641B
services
registration
RegistrationServer.java 814B
accounts
AccountsServer.java 2KB
web
HomeController.java 336B
Account.java 1KB
WebAccountsService.java 2KB
WebAccountsController.java 3KB
SearchCriteria.java 2KB
WebServer.java 2KB
Main.java 1KB
accounts
AccountsConfiguration.java 2KB
HomeController.java 333B
Account.java 2KB
AccountsController.java 3KB
AccountRepository.java 1KB
test
java
io
pivotal
microservices
accounts
AbstractAccountControllerTests.java 3KB
AccountsControllerIntegrationTests.java 1015B
AccountsControllerTests.java 1KB
diagrams.odp 250KB
pom.xml 3KB
mini-system.jpg 36KB
README.md 4KB
gradle.properties 323B
shopping-system.jpg 78KB
dashboard.png 214KB
共 56 条
- 1
资源评论
kingwin28
- 粉丝: 29
- 资源: 43
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于yolov5识别算法实现的DNF自动脚本源码.zip
- 基于Python实现的自动化办公项目.zip
- 基于python实现的基于PyQt5和爬虫的小说阅读系统.zip
- 机械设计整经机上纱自动化sw20非常好的设计图纸100%好用.zip
- Screenshot_20240427_031602.jpg
- 网页PDF_2024年04月26日 23-46-14_QQ浏览器网页保存_QQ浏览器转格式(6).docx
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功