{"id":1986,"date":"2017-05-11T14:39:17","date_gmt":"2017-05-11T12:39:17","guid":{"rendered":"http:\/\/blog.rabahi.net\/?page_id=1986"},"modified":"2017-05-11T14:43:22","modified_gmt":"2017-05-11T12:43:22","slug":"java-spring-microservices","status":"publish","type":"page","link":"https:\/\/blog.rabahi.net\/?page_id=1986","title":{"rendered":"Java Spring &#8211; MicroServices"},"content":{"rendered":"<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#Prerequistes\"><span class=\"toc_number toc_depth_1\">1<\/span> Prerequistes<\/a><\/li><li><a href=\"#Configuration\"><span class=\"toc_number toc_depth_1\">2<\/span> Configuration<\/a><\/li><li><a href=\"#Server_Part\"><span class=\"toc_number toc_depth_1\">3<\/span> Server Part<\/a><\/li><li><a href=\"#Client_Part\"><span class=\"toc_number toc_depth_1\">4<\/span> Client Part<\/a><ul><li><a href=\"#applicationyml\"><span class=\"toc_number toc_depth_2\">4.1<\/span> application.yml<\/a><\/li><li><a href=\"#boostrapyml\"><span class=\"toc_number toc_depth_2\">4.2<\/span> boostrap.yml<\/a><\/li><\/ul><\/li><\/ul><\/div>\n<h1><span id=\"Prerequistes\">Prerequistes<\/span><\/h1>\n<p>Please read : <a href=\"?page_id=1549\">Java spring &#8211; quickstart<\/a><\/p>\n<h1><span id=\"Configuration\">Configuration<\/span><\/h1>\n<p>If you use maven, add this to your pom.xml<\/p>\n<pre lang=\"xml\">\r\n<dependencies>\r\n(...)\r\n\r\n  !-- Spring Cloud starter -->\r\n  <dependency>\r\n    <groupId>org.springframework.cloud<\/groupId>\r\n    <artifactId>spring-cloud-starter<\/artifactId>\r\n  <\/dependency>\r\n\r\n  <!-- Eureka for service registration -->\r\n  <dependency>\r\n    <groupId>org.springframework.cloud<\/groupId>\r\n    <artifactId>spring-cloud-starter-eureka-server<\/artifactId>\r\n  <\/dependency>\r\n\r\n(...)\r\n<\/dependencies>\r\n<\/pre>\n<h1><span id=\"Server_Part\">Server Part<\/span><\/h1>\n<p>Enable eureka server :<\/p>\n<pre lang=\"java\">\r\n@EnableEurekaServer\r\n@EnableDiscoveryClient\r\npublic class EurekaServerConfiguration {\r\n  \/\/ empty.\r\n}\r\n<\/pre>\n<h1><span id=\"Client_Part\">Client Part<\/span><\/h1>\n<p>Enable eureka client :<\/p>\n<pre lang=\"java\">\r\n@EnableEurekaClient\r\n@EnableDiscoveryClient\r\npublic class EurekaClientConfiguration {\r\n  \/\/ empty.\r\n}\r\n<\/pre>\n<h2><span id=\"applicationyml\">application.yml<\/span><\/h2>\n<p>Create the file src\/main\/resources\/application.yml :<\/p>\n<pre lang=\"yml\">\r\neureka:\r\n  instance:\r\n    leaseRenewalIntervalInSeconds: 10\r\n  client:\r\n    registryFetchIntervalSeconds: 5\r\n    serviceUrl:\r\n      defaultZone: http:\/\/${server.hostname}:${server.port}\/eureka\/\r\n\r\nspring.application.name: myservice\r\n<\/pre>\n<h2><span id=\"boostrapyml\">boostrap.yml<\/span><\/h2>\n<p>Create the file src\/main\/resources\/boostrap.yml :<\/p>\n<pre lang=\"yml\">\r\nspring:\r\n  cloud:\r\n    config:\r\n      enabled: false\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 Prerequistes2 Configuration3 Server Part4 Client Part4.1 application.yml4.2 boostrap.yml Prerequistes Please read : Java spring &#8211; quickstart Configuration If you use maven, add this to your pom.xml (&#8230;) !&#8211; Spring Cloud starter &#8211;> org.springframework.cloud spring-cloud-starter org.springframework.cloud spring-cloud-starter-eureka-server (&#8230;) Server Part Enable eureka server : @EnableEurekaServer @EnableDiscoveryClient public class EurekaServerConfiguration { \/\/ empty. } Client Part [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1547,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1986","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1986","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1986"}],"version-history":[{"count":4,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1986\/revisions"}],"predecessor-version":[{"id":1990,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1986\/revisions\/1990"}],"up":[{"embeddable":true,"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=\/wp\/v2\/pages\/1547"}],"wp:attachment":[{"href":"https:\/\/blog.rabahi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1986"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}