{"id":297640,"date":"2020-01-24T15:00:28","date_gmt":"2020-01-24T15:00:28","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=297640"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=297640","title":{"rendered":"\u041c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043e Spring Boot. \u0427\u0430\u0441\u0442\u044c 3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442"},"content":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/485094\/\">\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Boot \u0438 Spring Cloud.<\/p>\n<p>  \u042d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441\u043e Spring Boot.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u0430\u0440\u0443 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043c \u0438\u0445 \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043c\u0435\u043d Eureka (Eureka Naming Server) \u0438 Ribbon \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430.<\/p>\n<p>  \u042d\u0442\u043e \u0441\u0442\u0430\u0442\u044c\u044f \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439 \u00ab\u041c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043e Spring Boot\u00bb:<\/p>\n<ul>\n<li><a href=\"https:\/\/habr.com\/post\/484130\/\">\u0427\u0430\u0441\u0442\u044c 1. \u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u043e\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432<\/a><\/li>\n<li><a href=\"https:\/\/habr.com\/ru\/post\/484864\/\">\u0427\u0430\u0441\u0442\u044c 2. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 Forex<\/a><\/li>\n<li>\u0427\u0430\u0441\u0442\u044c 3. \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442<\/li>\n<li>\u0427\u0430\u0441\u0442\u044c 4. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Ribbon \u0434\u043b\u044f \u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u043a\u0438 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438<\/li>\n<li>\u0427\u0430\u0441\u0442\u044c 5. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u0438\u043c\u0435\u043d Eureka<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0412\u044b \u0438\u0437\u0443\u0447\u0438\u0442\u0435<\/h3>\n<p>  <\/p>\n<ul>\n<li>\u041a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Boot.<\/li>\n<li>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c RestTemplate \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f REST \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/li>\n<li>\u041a\u0430\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Feign \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f REST \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/li>\n<li>\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 Feign \u043f\u0435\u0440\u0435\u0434 RestTemplate.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u041e\u0431\u0437\u043e\u0440 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h3>\n<p>  \u0421\u0435\u0440\u0432\u0438\u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442 (CCS) \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0432\u0430\u043b\u044e\u0442 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0432\u0430\u043b\u044e\u0442\u0443. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Forex \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0442\u0435\u043a\u0443\u0449\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0431\u043c\u0435\u043d\u0430 \u0432\u0430\u043b\u044e\u0442\u044b. CCS \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u043c \u0443\u0441\u043b\u0443\u0433.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0442\u0432\u0435\u0442\u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"xml\">GET to http:\/\/localhost:8100\/currency-converter\/from\/EUR\/to\/INR\/quantity\/10000<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"json\">{   id: 10002,   from: &quot;EUR&quot;,   to: &quot;INR&quot;,   conversionMultiple: 75,   quantity: 10000,   totalCalculatedAmount: 750000,   port: 8000, }<\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0440\u043e\u0441 \u0432\u044b\u0448\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c 10000 \u0435\u0432\u0440\u043e \u0432 \u0438\u043d\u0434\u0438\u0439\u0441\u043a\u0438\u0445 \u0440\u0443\u043f\u0438\u044f\u0445.<br \/>  TotalCalculatedAmount \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 750000 INR. \u0414\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0430 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 CCS \u0438 FS.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a5\/fh\/x1\/a5fhx1oodjcmfpp8htw1nikm37k.png\"><\/p>\n<h3>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043a\u043e\u0434\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h3>\n<p>  \u041d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0441\u043a\u0440\u0438\u043d\u0448\u043e\u0442\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/1p\/bt\/p_\/1pbtp_ohwxqxaowuelzqdinmozg.png\"><\/p>\n<p>  \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<ul>\n<li><b>SpringBootMicroserviceCurrencyConversionApplication.java<\/b> \u2014 \u043a\u043b\u0430\u0441\u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spring Boot, \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Initializer. \u042d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442 \u043a\u0430\u043a \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/li>\n<li><b>pom.xml<\/b> \u2014 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spring Boot Starter Web.<\/li>\n<li><b>CurrencyConversionBean.java<\/b> \u2014 \u0411\u0438\u043d \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c.<\/li>\n<li><b>CurrencyExchangeServiceProxy.java<\/b> \u2014 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 Feign Proxy \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 Forex.<\/li>\n<li><b>CurrencyConversionController.java<\/b> \u2014 Spring REST \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442. \u041e\u043d \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c CurrencyExchangeServiceProxy \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 Forex.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f<\/h3>\n<p>  <\/p>\n<ul>\n<li>Maven 3.0+ \u2014 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0441\u0431\u043e\u0440\u043a\u0438<\/li>\n<li>\u0412\u0430\u0448 \u043b\u044e\u0431\u0438\u043c\u044b\u0439 IDE. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Eclipse.<\/li>\n<li>JDK 1.8+<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0413\u043e\u0442\u043e\u0432\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 Maven \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u0434\u0430<\/h3>\n<p>  <\/p>\n<blockquote><p>\u0412 <a href=\"https:\/\/github.com\/in28minutes\/spring-boot-examples\/tree\/master\/spring-boot-basic-microservice\" rel=\"nofollow\">Github \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438<\/a> \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430.<\/p><\/blockquote>\n<p>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Initializr<\/h3>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 Spring Initializr \u2014 \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f \u043f\u0440\u043e\u0433\u0443\u043b\u043a\u0430.<\/p>\n<p>  Spring Initializr\u2014 \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 Spring Boot.<\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/start.spring.io\" rel=\"nofollow\">Spring Initializr<\/a> \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0440\u0430\u0437\u043d\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/tp\/jb\/xm\/tpjbxmj7hptc0urwe4dqdzvixqs.png\"><\/p>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0432\u0435\u0431-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432:<\/p>\n<p>  1. \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 Spring Initializr \u0438 \u043d\u0430\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<ul>\n<li>\u041d\u0430\u0431\u0435\u0440\u0438\u0442\u0435 <b>com.in28minutes.springboot.microservice.example.currencyconversion<\/b> \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0433\u0440\u0443\u043f\u043f\u044b.<\/li>\n<li>\u041d\u0430\u0431\u0435\u0440\u0438\u0442\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0442\u0435\u0444\u0430\u043a\u0442\u0430 <b>spring-boot-microservice-currency-conversion<\/b>.<\/li>\n<li>\u0412\u044b\u0431\u0435\u0440\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438: <b>Web<\/b>, <b>DevTools<\/b>, <b>Feign<\/b><\/li>\n<\/ul>\n<p>  2. \u041d\u0430\u0436\u043c\u0438\u0442\u0435 <b>Generate Project<\/b>.<\/p>\n<p>  3. \u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Eclipse: File -&gt; Import -&gt; Existing Maven Project.<\/p>\n<p>  <b>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435<\/b> \u0443\u043a\u0430\u0437\u0430\u0442\u044c <b>Feign<\/b> \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u0445.<\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 CurrencyConversionBean <\/h3>\n<p>  \u042d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u0438\u043d \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0442\u0432\u0435\u0442\u0430.  <\/p>\n<pre><code class=\"java\">public class CurrencyConversionBean {   private Long id;   private String from;   private String to;   private BigDecimal conversionMultiple;   private BigDecimal quantity;   private BigDecimal totalCalculatedAmount;   private int port;   public CurrencyConversionBean() {   }   public CurrencyConversionBean(Long id, String from, String to, BigDecimal conversionMultiple, BigDecimal quantity,       BigDecimal totalCalculatedAmount, int port) {     super();     this.id = id;     this.from = from;     this.to = to;     this.conversionMultiple = conversionMultiple;     this.quantity = quantity;     this.totalCalculatedAmount = totalCalculatedAmount;     this.port = port;   }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f REST-\u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 RestTemplate <\/h3>\n<p>  \u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043d\u0438\u0436\u0435 \u043a\u043e\u0434 \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e REST \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u0435\u0440\u0432\u0438\u0441\u0430 Forex \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043e\u0442\u0432\u0435\u0442\u0430. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u0430 \u0441\u043b\u0443\u0436\u0431\u044b \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"java\">@RestController public class CurrencyConversionController {   private Logger logger = LoggerFactory.getLogger(this.getClass());   @GetMapping(&quot;\/currency-converter\/from\/{from}\/to\/{to}\/quantity\/{quantity}&quot;)   public CurrencyConversionBean convertCurrency(@PathVariable String from, @PathVariable String to,       @PathVariable BigDecimal quantity) {     Map&lt;String, String&gt; uriVariables = new HashMap&lt;&gt;();     uriVariables.put(&quot;from&quot;, from);     uriVariables.put(&quot;to&quot;, to);     ResponseEntity&lt;CurrencyConversionBean&gt; responseEntity = new RestTemplate().getForEntity(         &quot;http:\/\/localhost:8000\/currency-exchange\/from\/{from}\/to\/{to}&quot;, CurrencyConversionBean.class,         uriVariables);     CurrencyConversionBean response = responseEntity.getBody();     return new CurrencyConversionBean(response.getId(), from, to, response.getConversionMultiple(), quantity,         quantity.multiply(response.getConversionMultiple()), response.getPort());   }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0440\u0442\u0430<\/h3>\n<p>  <b>\/spring-boot-microservice-currency-conversion-service\/src\/main\/resources\/application.properties<\/b><\/p>\n<pre><code class=\"xml\">spring.application.name=currency-conversion-service server.port=8100<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 <\/h3>\n<p>  \u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 Spring Boot \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0432 SpringBootMicroserviceCurrencyConversionApplication.java<\/p>\n<pre><code class=\"xml\">GET to http:\/\/localhost:8100\/currency-converter\/from\/EUR\/to\/INR\/quantity\/10000<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"json\">{   id: 10002,   from: &quot;EUR&quot;,   to: &quot;INR&quot;,   conversionMultiple: 75,   quantity: 10000,   totalCalculatedAmount: 750000,   port: 8000, }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 Feign \u043f\u0440\u043e\u043a\u0441\u0438 <\/h3>\n<p>  Feign \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043b\u0443\u0447\u0448\u0443\u044e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0443 RestTemplate \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 REST API.<\/p>\n<p>  <b>\/spring-boot-microservice-currency-conversion-service\/src\/main\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/CurrencyExchangeServiceProxy.java<br \/>  <\/b>  <\/p>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable;  @FeignClient(name=&quot;forex-service&quot; url=&quot;localhost:8000&quot;) public interface CurrencyExchangeServiceProxy {   @GetMapping(&quot;\/currency-exchange\/from\/{from}\/to\/{to}&quot;)   public CurrencyConversionBean retrieveExchangeValue     (@PathVariable(&quot;from&quot;) String from, @PathVariable(&quot;to&quot;) String to); }<\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u043a\u0441\u0438:<\/p>\n<ul>\n<li><b>@FeignClient(name=\u00abforex-service\u00bb url=\u00ablocalhost:8100\u00bb)<\/b> \u2014 \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u0442, \u0447\u0442\u043e \u044d\u0442\u043e Feign \u043a\u043b\u0438\u0435\u043d\u0442, \u0430 URL-\u0430\u0434\u0440\u0435\u0441, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u043c\u0435\u0435\u0442\u0441\u044f Forex \u0441\u0435\u0440\u0432\u0438\u0441, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f localhost: 8100 <\/li>\n<li><b>@GetMapping(&quot;\/currency-exchange\/from\/{from}\/to\/{to}&quot;)<\/b> \u2014 URI \u0441\u043b\u0443\u0436\u0431\u044b, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Feign \u043f\u0440\u043e\u043a\u0441\u0438 \u0432 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 <\/h3>\n<p>  \u0412\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u0430 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043a\u0441\u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e. \u0412\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u044d\u0442\u043e \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438 \u0432 \u043a\u043e\u0434\u0435 \u043d\u0438\u0436\u0435. \u0412\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u044d\u0442\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043f\u0440\u043e\u043a\u0441\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430.<\/p>\n<pre><code class=\"java\">@Autowired   private CurrencyExchangeServiceProxy proxy;   @GetMapping(&quot;\/currency-converter-feign\/from\/{from}\/to\/{to}\/quantity\/{quantity}&quot;)   public CurrencyConversionBean convertCurrencyFeign(@PathVariable String from, @PathVariable String to,       @PathVariable BigDecimal quantity) {     CurrencyConversionBean response = proxy.retrieveExchangeValue(from, to);     logger.info(&quot;{}&quot;, response);     return new CurrencyConversionBean(response.getId(), from, to, response.getConversionMultiple(), quantity,         quantity.multiply(response.getConversionMultiple()), response.getPort());   }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0412\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 Feign \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 <\/h2>\n<p>  \u041f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Feign, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0435\u0433\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 @EnableFeignClients \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c \u043f\u0430\u043a\u0435\u0442\u0435, \u0433\u0434\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043a\u043b\u0438\u0435\u043d\u0442\u0441\u043a\u0438\u0435 \u043f\u0440\u043e\u043a\u0441\u0438.<\/p>\n<pre><code class=\"java\">@SpringBootApplication @EnableFeignClients(&quot;com.in28minutes.springboot.microservice.example.currencyconversion&quot;) @EnableDiscoveryClient public class SpringBootMicroserviceCurrencyConversionApplication {   public static void main(String[] args) {     SpringApplication.run(SpringBootMicroserviceCurrencyConversionApplication.class, args);   } }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c Feign<\/h2>\n<p>  <\/p>\n<pre><code class=\"xml\">GET to http:\/\/localhost:8100\/currency-converter-feign\/from\/EUR\/to\/INR\/quantity\/10000<\/code><\/pre>\n<pre><code class=\"json\">{   id: 10002,   from: &quot;EUR&quot;,   to: &quot;INR&quot;,   conversionMultiple: 75,   quantity: 10000,   totalCalculatedAmount: 750000,   port: 8000, }<\/code><\/pre>\n<p>  <\/p>\n<h2>\u0420\u0435\u0437\u044e\u043c\u0435<\/h2>\n<p>  \u041c\u044b \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u0434\u0432\u0430 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438 \u0441\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/a5\/fh\/x1\/a5fhx1oodjcmfpp8htw1nikm37k.png\"><\/p>\n<p>  \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u043c\u044b \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043b\u0438 URL \u0434\u043b\u044f FS \u0432 CCS. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b FS, \u0443 \u043d\u0430\u0441 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Ribbon.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<h4>\/spring-boot-microservice-currency-conversion-service\/pom.xml<\/h4>\n<p>  <\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; &lt;project xmlns=&quot;http:\/\/maven.apache.org\/POM\/4.0.0&quot; xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;   xsi:schemaLocation=&quot;http:\/\/maven.apache.org\/POM\/4.0.0 http:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd&quot;&gt;   &lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;   &lt;groupId&gt;com.in28minutes.springboot.microservice.example.currency-conversion&lt;\/groupId&gt;   &lt;artifactId&gt;spring-boot-microservice-currency-conversion&lt;\/artifactId&gt;   &lt;version&gt;0.0.1-SNAPSHOT&lt;\/version&gt;   &lt;packaging&gt;jar&lt;\/packaging&gt;   &lt;name&gt;spring-boot-microservice-currency-conversion&lt;\/name&gt;   &lt;description&gt;Microservices with Spring Boot and Spring Cloud - Currency Conversion Service&lt;\/description&gt;   &lt;parent&gt;     &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;     &lt;artifactId&gt;spring-boot-starter-parent&lt;\/artifactId&gt;     &lt;version&gt;2.0.0.M3&lt;\/version&gt;     &lt;relativePath \/&gt; &lt;!-- lookup parent from repository --&gt;   &lt;\/parent&gt;   &lt;properties&gt;     &lt;project.build.sourceEncoding&gt;UTF-8&lt;\/project.build.sourceEncoding&gt;     &lt;project.reporting.outputEncoding&gt;UTF-8&lt;\/project.reporting.outputEncoding&gt;     &lt;java.version&gt;1.8&lt;\/java.version&gt;     &lt;spring-cloud.version&gt;Finchley.M2&lt;\/spring-cloud.version&gt;   &lt;\/properties&gt;   &lt;dependencies&gt;     &lt;dependency&gt;       &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;       &lt;artifactId&gt;spring-boot-starter-web&lt;\/artifactId&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;       &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;       &lt;artifactId&gt;spring-cloud-starter-feign&lt;\/artifactId&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;       &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;       &lt;artifactId&gt;spring-boot-devtools&lt;\/artifactId&gt;       &lt;scope&gt;runtime&lt;\/scope&gt;     &lt;\/dependency&gt;     &lt;dependency&gt;       &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;       &lt;artifactId&gt;spring-boot-starter-test&lt;\/artifactId&gt;       &lt;scope&gt;test&lt;\/scope&gt;     &lt;\/dependency&gt;   &lt;\/dependencies&gt;   &lt;dependencyManagement&gt;     &lt;dependencies&gt;       &lt;dependency&gt;         &lt;groupId&gt;org.springframework.cloud&lt;\/groupId&gt;         &lt;artifactId&gt;spring-cloud-dependencies&lt;\/artifactId&gt;         &lt;version&gt;${spring-cloud.version}&lt;\/version&gt;         &lt;type&gt;pom&lt;\/type&gt;         &lt;scope&gt;import&lt;\/scope&gt;       &lt;\/dependency&gt;     &lt;\/dependencies&gt;   &lt;\/dependencyManagement&gt;   &lt;build&gt;     &lt;plugins&gt;       &lt;plugin&gt;         &lt;groupId&gt;org.springframework.boot&lt;\/groupId&gt;         &lt;artifactId&gt;spring-boot-maven-plugin&lt;\/artifactId&gt;       &lt;\/plugin&gt;     &lt;\/plugins&gt;   &lt;\/build&gt;   &lt;repositories&gt;     &lt;repository&gt;       &lt;id&gt;spring-snapshots&lt;\/id&gt;       &lt;name&gt;Spring Snapshots&lt;\/name&gt;       &lt;url&gt;https:\/\/repo.spring.io\/snapshot&lt;\/url&gt;       &lt;snapshots&gt;         &lt;enabled&gt;true&lt;\/enabled&gt;       &lt;\/snapshots&gt;     &lt;\/repository&gt;     &lt;repository&gt;       &lt;id&gt;spring-milestones&lt;\/id&gt;       &lt;name&gt;Spring Milestones&lt;\/name&gt;       &lt;url&gt;https:\/\/repo.spring.io\/milestone&lt;\/url&gt;       &lt;snapshots&gt;         &lt;enabled&gt;false&lt;\/enabled&gt;       &lt;\/snapshots&gt;     &lt;\/repository&gt;   &lt;\/repositories&gt;   &lt;pluginRepositories&gt;     &lt;pluginRepository&gt;       &lt;id&gt;spring-snapshots&lt;\/id&gt;       &lt;name&gt;Spring Snapshots&lt;\/name&gt;       &lt;url&gt;https:\/\/repo.spring.io\/snapshot&lt;\/url&gt;       &lt;snapshots&gt;         &lt;enabled&gt;true&lt;\/enabled&gt;       &lt;\/snapshots&gt;     &lt;\/pluginRepository&gt;     &lt;pluginRepository&gt;       &lt;id&gt;spring-milestones&lt;\/id&gt;       &lt;name&gt;Spring Milestones&lt;\/name&gt;       &lt;url&gt;https:\/\/repo.spring.io\/milestone&lt;\/url&gt;       &lt;snapshots&gt;         &lt;enabled&gt;false&lt;\/enabled&gt;       &lt;\/snapshots&gt;     &lt;\/pluginRepository&gt;   &lt;\/pluginRepositories&gt; &lt;\/project&gt;<\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/main\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/CurrencyConversionBean.java<\/h4>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import java.math.BigDecimal;  public class CurrencyConversionBean {   private Long id;   private String from;   private String to;   private BigDecimal conversionMultiple;   private BigDecimal quantity;   private BigDecimal totalCalculatedAmount;   private int port;   public CurrencyConversionBean() {   }   public CurrencyConversionBean(Long id, String from, String to, BigDecimal conversionMultiple, BigDecimal quantity,       BigDecimal totalCalculatedAmount, int port) {     super();     this.id = id;     this.from = from;     this.to = to;     this.conversionMultiple = conversionMultiple;     this.quantity = quantity;     this.totalCalculatedAmount = totalCalculatedAmount;     this.port = port;   }   public Long getId() {     return id;   }   public void setId(Long id) {     this.id = id;   }   public String getFrom() {     return from;   }   public void setFrom(String from) {     this.from = from;   }   public String getTo() {     return to;   }   public void setTo(String to) {     this.to = to;   }   public BigDecimal getConversionMultiple() {     return conversionMultiple;   }   public void setConversionMultiple(BigDecimal conversionMultiple) {     this.conversionMultiple = conversionMultiple;   }   public BigDecimal getQuantity() {     return quantity;   }   public void setQuantity(BigDecimal quantity) {     this.quantity = quantity;   }   public BigDecimal getTotalCalculatedAmount() {     return totalCalculatedAmount;   }   public void setTotalCalculatedAmount(BigDecimal totalCalculatedAmount) {     this.totalCalculatedAmount = totalCalculatedAmount;   }   public int getPort() {     return port;   }   public void setPort(int port) {     this.port = port;   } }<\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/main\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/CurrencyConversionController.java<\/h4>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate;  @RestController public class CurrencyConversionController {   private Logger logger = LoggerFactory.getLogger(this.getClass());   @Autowired   private CurrencyExchangeServiceProxy proxy;   @GetMapping(&quot;\/currency-converter\/from\/{from}\/to\/{to}\/quantity\/{quantity}&quot;)   public CurrencyConversionBean convertCurrency(@PathVariable String from, @PathVariable String to,       @PathVariable BigDecimal quantity) {     Map&lt;String, String&gt; uriVariables = new HashMap&lt;&gt;();     uriVariables.put(&quot;from&quot;, from);     uriVariables.put(&quot;to&quot;, to);     ResponseEntity&lt;CurrencyConversionBean&gt; responseEntity = new RestTemplate().getForEntity(         &quot;http:\/\/localhost:8000\/currency-exchange\/from\/{from}\/to\/{to}&quot;, CurrencyConversionBean.class,         uriVariables);     CurrencyConversionBean response = responseEntity.getBody();     return new CurrencyConversionBean(response.getId(), from, to, response.getConversionMultiple(), quantity,         quantity.multiply(response.getConversionMultiple()), response.getPort());   }   @GetMapping(&quot;\/currency-converter-feign\/from\/{from}\/to\/{to}\/quantity\/{quantity}&quot;)   public CurrencyConversionBean convertCurrencyFeign(@PathVariable String from, @PathVariable String to,       @PathVariable BigDecimal quantity) {     CurrencyConversionBean response = proxy.retrieveExchangeValue(from, to);     logger.info(&quot;{}&quot;, response);     return new CurrencyConversionBean(response.getId(), from, to, response.getConversionMultiple(), quantity,         quantity.multiply(response.getConversionMultiple()), response.getPort());   } }<\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/main\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/CurrencyExchangeServiceProxy.java<\/h4>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable;  @FeignClient(name=&quot;forex-service&quot; url=&quot;localhost:8000&quot;) public interface CurrencyExchangeServiceProxy {   @GetMapping(&quot;\/currency-exchange\/from\/{from}\/to\/{to}&quot;)   public CurrencyConversionBean retrieveExchangeValue     (@PathVariable(&quot;from&quot;) String from, @PathVariable(&quot;to&quot;) String to); }<\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/main\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/SpringBootMicroserviceCurrencyConversionApplication.java<\/h4>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.feign.EnableFeignClients;  @SpringBootApplication @EnableFeignClients(&quot;com.in28minutes.springboot.microservice.example.currencyconversion&quot;) public class SpringBootMicroserviceCurrencyConversionApplication {   public static void main(String[] args) {     SpringApplication.run(SpringBootMicroserviceCurrencyConversionApplication.class, args);   } } <\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/main\/resources\/application.properties<\/h4>\n<pre><code class=\"xml\">spring.application.name=currency-conversion-service server.port=8100<\/code><\/pre>\n<h4>\/spring-boot-microservice-currency-conversion-service\/src\/test\/java\/com\/in28minutes\/springboot\/microservice\/example\/currencyconversion\/SpringBootMicroserviceCurrencyConversionApplicationTests.java<\/h4>\n<pre><code class=\"java\">package com.in28minutes.springboot.microservice.example.currencyconversion;  import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;  @RunWith(SpringRunner.class) @SpringBootTest public class SpringBootMicroserviceCurrencyConversionApplicationTests {   @Test   public void contextLoads() {   } }<\/code><\/pre>\n<\/p><\/div>\n<\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/485094\/\"> https:\/\/habr.com\/ru\/post\/485094\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/485094\/\">\u042d\u0442\u043e \u0442\u0440\u0435\u0442\u044c\u044f \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u0430\u043c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0435\u0440\u0438\u0438 \u0441\u0442\u0430\u0442\u0435\u0439 \u0432\u044b \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u0441 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0443\u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Spring Boot \u0438 Spring Cloud.<\/p>\n<p>  \u042d\u0442\u043e \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u044b \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u044b\u0445 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440. \u041c\u044b \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0441\u043e Spring Boot.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-297640","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297640","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=297640"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/297640\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=297640"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=297640"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=297640"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}