Integrate spring Cloud cloud service architecture-Commonservice-eureka project build process

Source: Internet
Author: User

We build the following for the Eureka project of Honghu Cloud, the whole construction process is simple, I will record every step of the construction process, I hope to help everyone:

1. Create a MAVEN project named Particle-common-eureka, inheriting Particle-commonservice, with the following pom.xml configuration file:

XML code
  1. <? XML version= "1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance "
  3. xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
  4. <modelversion>4.0.0</modelversion>
  5. <parent>
  6. <groupId>com.ml.honghu</groupId>
  7. <artifactid>particle-commonservice</artifactid>
  8. <version>0.0.1-snapshot</version>
  9. </Parent>
  10. <artifactid>particle-commonservice-eureka</artifactid>
  11. <packaging>jar</packaging>
  12. <name>particle-commonservice-eureka</name>
  13. <description>particle-commonservice project for Spring Boot</Description >
  14. <dependencies>
  15. <dependency>
  16. <groupId>org.springframework.cloud</groupId>
  17. <artifactid>spring-cloud-starter-eureka-server</artifactid>
  18. </Dependency>
  19. <dependency>
  20. <groupId>org.springframework.boot</groupId>
  21. <artifactid>spring-boot-starter-security</artifactid>
  22. </Dependency>
  23. <dependency>
  24. <groupId>org.springframework.boot</groupId>
  25. <artifactid>spring-boot-devtools</artifactid>
  26. </Dependency>
  27. <dependency>
  28. <groupId>org.springframework.boot</groupId>
  29. <artifactid>spring-boot-starter-test</artifactid>
  30. <scope>test</scope>
  31. </Dependency>
  32. </Dependencies>
  33. <build>
  34. <plugins>
  35. <plugin>
  36. <groupId>org.springframework.boot</groupId>
  37. <artifactid>spring-boot-maven-plugin</artifactid>
  38. <executions>
  39. <execution>
  40. <ID>1</ID>
  41. <goals>
  42. <goal>repackage</goal>
  43. </Goals>
  44. </Execution>
  45. <execution>
  46. <ID>2</ID>
  47. <goals>
  48. <goal>build-info</goal>
  49. </Goals>
  50. </Execution>
  51. </Executions>
  52. <configuration>
  53. <executable>true</executable>
  54. </configuration>
  55. </plugin>
  56. </plugins>
  57. </Build>
  58. </Project>

2. In the Boot class entry reference Eureka configuration, the code is as follows:

Java code
  1. Package Com.ml.honghu;
  2. Import org.springframework.boot.SpringApplication;
  3. Import org.springframework.boot.autoconfigure.SpringBootApplication;
  4. Import Org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
  5. @EnableEurekaServer
  6. @SpringBootApplication
  7. Public class Serviceapplication {
  8. public static void Main (string[] args) {
  9. Springapplication.run (serviceapplication.   class, args);
  10. }
  11. }

3. Configuring the Application.yml File

XML code
  1. # server (Eureka default port is: 8761)
  2. Server
  3. port:8761
  4. # Spring
  5. Spring
  6. Application:
  7. Name:particle-commonservice-erueka
  8. # Eureka
  9. Eureka
  10. Client
  11. # whether to register to Eureka
  12. Register-with-eureka:true
  13. # Whether to get registration information from Eureka
  14. Fetch-registry:false
  15. Availability-zones:
  16. Honghu:honghuzone
  17. Service-url:
  18. Honghuzone:http://honghu:[email protected]:8761/eureka/
  19. Defaultzone:http://honghu:[email protected]:8761/eureka/
  20. Instance
  21. Prefer-ip-address:true
  22. Hostname:localhost
  23. Metadatamap:
  24. Zone:honghuzone
  25. User: ${security.user.name}
  26. Password: {Security.user.password}
  27. # Specify the Environment
  28. Environment:dev
  29. #指定数据中心
  30. Datacenter:honghu
  31. # Turn off self-protection mode
  32. Server
  33. Enable-self-preservation:false
  34. #设置清理无效节点的时间间隔, default 60000, which is 60s
  35. eviction-interval-timer-in-ms:60000
  36. # Service Certification
  37. Security
  38. Basic
  39. Enabled:true
  40. User
  41. Name:honghu
  42. password:123456
  43. Management
  44. Security
  45. Enabled:false

4. Add the log mechanism of the project and the package operation mechanism (we will write the package deployment mechanism for Linux CentOS in detail later)

5. From the completion of this entire project deployment, the run as-to-Spring Boot App is performed manually with the following results:

Console Run Results:

To access the console and log in:

Console Run Effect:

From now on, I will be documenting the process and essence of the recent development of the spring cloud micro-service cloud architecture to help more friends who are interested in developing the Spring cloud framework to explore the process of building the spring cloud architecture and how to use it in enterprise projects. Source of information source

Integrate spring Cloud cloud service architecture-Commonservice-eureka project build process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.