In the Dubbo Project (http://www.cnblogs.com/wenbronk/p/6774539.html), we used zookeeper as the cluster's registry, and in Springcloud, you can also use zookeeper , but the good plan is Eureka
About the principle of Eureka, have seen a few good blog
http://itmuch.com/spring-cloud-1/http://baike.renwuyi.com/2016-12/18938.htmlhttp://blog.csdn.net/jenny8080/ article/details/52448403http://blog.csdn.net/zipo/article/details/60588647
Next, create a new module named Eureka-discovery
Installation: 1, Pom.xml
<!--Springcloude-eureka Server-side dependency- <dependency> <groupId>org.springframework.cloud< /groupid> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency >
2, MainClass
Package Com.wenbronk.eureka;import Org.springframework.boot.springapplication;import Org.springframework.boot.autoconfigure.springbootapplication;import Org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; /* */@SpringBootApplication @enableeurekaserverpublicclass eurekaapplication { publicstaticvoid main (string[] args) { Springapplication.run (eurekaapplication. class , args);} }
3, Application.yml
Server: 8761 # Context-path:/Eurekaeureka: client: # do not use register false as client fetchfalse service-URL: defaultzone:http:// localhost:8761/eureka/
Eureka start, will default to themselves register a copy of their own application, here we use a stand-alone, so it can be banned
4, Log4j2.yml
Self-configuring ...
In this way, launching the app will allow you to have a Eureka registration center.
Access via web:
Password Login configuration:
With Springcloud's official documentation, you can see that the Springcloud can be password-logged via URL::
Added in Pom.xml:
<!--Add this dependency to set the password-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
Then change the application.yml to the following:
Security: basic: true User: name:wenbronk password:a75767626server: 8761 # Context-path:/Eurekaeureka: client: # do not use register as Client False fetchfalse service-URL: defaultzone:http: //wenbronk:[email protected]:8761/eureka/
At this time through the browser access, you need to enter a user name and password to login
Springcloud-01-eureka