(八)整合spring cloud云服务架构 - commonservice-eureka 项目构建过程

咱们针对于HongHu cloud的eureka项目作如下构建,整个构建的过程很简单,我会将每一步都构建过程记录下来,但愿能够帮助到你们:html

1. 建立一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件以下:spring

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
 
    <parent>
        <groupId>com.ml.honghu</groupId>
        <artifactId>particle-commonservice</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
 
    <artifactId>particle-commonservice-eureka</artifactId>
    <packaging>jar</packaging>
 
    <name>particle-commonservice-eureka</name>
    <description>particle-commonservice project for Spring Boot</description>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
 
    </dependencies>
 
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>1</id>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>2</id>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>true</executable>
                </configuration>
                
            </plugin>
        </plugins>
    </build>
</project>复制代码

 2. 在启动类入口引用eureka的相关配置,代码以下:
apache

package com.ml.honghu;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
 
@EnableEurekaServer
@SpringBootApplication
public class ServiceApplication {
 
    public static void main(String[] args) {
        SpringApplication.run(ServiceApplication.class, args);
    }
}复制代码

3. 配置application.yml文件bash

4. 增长项目的log机制和打包运行机制(后面咱们会详细编写针对于Linux Centos下的打包部署机制)架构

5. 自此整个项目部署完成,经过手动方式进行Run As --> Spring Boot App,运行结果以下:app

控制台运行结果:框架

访问控制台并登录:maven

控制台运行效果:分布式

从如今开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,你们来一块儿探讨spring cloud架构的搭建过程及如何运用于企业项目。完整项目的源码来源 spring-boot

 Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码请加企鹅求求: 一零叁八七七四六贰

相关文章
相关标签/搜索