`
springcloud关注者
  • 浏览: 309581 次
  • 性别: Icon_minigender_1
  • 来自: 北京
博客专栏
12d8ea3d-4199-3941-8a17-acd5024729b8
Spring_Cloud构...
浏览量:249682
文章分类
社区版块
存档分类
最新评论

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

阅读更多

我们针对于HongHu cloud的eureka项目做以下构建,整个构建的过程很简单,我会将每一步都构建过程记录下来,希望可以帮助到大家:

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

 

<?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的相关配置,代码如下:

 

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文件

# server (eureka 默认端口为:8761)
server:
  port: 8761

# spring
spring:
  application:
    name: particle-commonservice-erueka

# eureka
eureka: 
  client: 
    # 是否注册到eureka
    register-with-eureka: true
    # 是否从eureka获取注册信息
    fetch-registry: false
    availability-zones: 
      honghu: honghuZone
    service-url: 
      honghuZone: http://honghu:123456@localhost:8761/eureka/
      defaultZone: http://honghu:123456@localhost:8761/eureka/
  instance:
    prefer-ip-address: true
    hostname: localhost
    metadataMap:
      zone: honghuZone
      user: ${security.user.name}
      password: {security.user.password}
      
  # 指定环境
  environment: dev
  #指定数据中心
  datacenter: honghu
  # 关闭自我保护模式
  server: 
    enable-self-preservation: false
  #设置清理无效节点的时间间隔,默认60000,即是60s
    eviction-interval-timer-in-ms: 60000

# 服务认证
security: 
  basic: 
    enabled: true
  user: 
    name: honghu
    password: 123456

management:
  security:
    enabled: false

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

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

控制台运行结果:

 

访问控制台并登陆:

 

控制台运行效果:

从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。

 

分享到:
评论
2 楼 mabusyao 2017-10-17  
源代码放到Github上去呗
1 楼 jxgaly 2017-10-17  
大神,为何没有第八篇呢?

相关推荐

    eureka分布式微服务

    1. **`spring-cloud-starter-eureka-server`**:这是Eureka服务端的核心依赖,用于构建服务发现中心。 2. **`spring-boot-starter-security`**:提供了Spring Security的安全框架支持,可以用于对Eureka服务进行安全...

    鸿鹄Cloud分布式微服务云系统管理_springcloud_分布式_产品_云_平台_

    Commonservice-system 是一个大型分布式、微服务、面向企业的 JavaEE 体系快速研发平台,基于模块化、服务化、原子化、热插拔的设计思想,使用成熟领先的无商业限制的主流开源技术构建。 采用服务化的组件开发模式,...

    spring cloud consul使用ip注册服务的方法示例

    其次,我们需要添加 `instance-id` 属性,并将其设置为 `${spring.application.name}:${spring.cloud.client.ip-address}`。这将使 Consul 使用 IP 地址来注册服务。 ```yaml spring: cloud: consul: host: xxx....

    17.5、利用反射调用webservice1

    本文主要涉及了如何利用Java反射机制来调用Web Service,以及与之相关的Spring框架集成。以下是对这些知识点的详细说明: 1. **Web Service发布**: - Web Service是一种基于XML的接口,使得不同的应用系统可以...

    大数据分析系统

    ### 二、技术架构与实现细节 #### 1. 技术栈 - **Java**: 作为主要开发语言。 - **Spring Framework**: 提供了MVC框架支持,使得应用程序能够更好地进行分层设计。 - **Spring Web MVC**: 控制器类采用了@...

    Spring循环依赖报错Bean with name ‘**’ has been injected into other beans [**] in its raw version as part

    has been injected into other beans [] in its raw version as part of a circular reference, but has eventually been wrapped”表明`commonService` Bean与其他Bean存在循环依赖,但在处理过程中已被适当地包裹...

    unity对接网狐服务器文档

    网狐棋牌服务器以其稳定性和高质量的代码著称,对于希望构建棋牌游戏平台的开发者而言具有很高的参考价值。网狐不仅提供了完整的服务器端代码,还包含了一系列客户端的实现方案。 - **服务器特点**: - 高稳定性与...

    java毕设项目之基于java+springboot科研工作量管理系统的设计与实现.zip

    它简化了Java应用的构建过程,使得开发者可以更专注于业务逻辑而不是基础设施的配置。通过SpringBoot,我们可以轻松集成如数据库连接、模板引擎、安全控制等多个组件,极大地提高了开发效率。 项目中使用了MySQL...

    2、webservice--常用注解1

    WebService 是一种基于 XML 的远程过程调用(RPC)技术,它允许不同的系统之间通过网络进行通信。在 Java 中,WebService 通常使用 JAX-WS(Java API for XML-Based Web Services)来实现。为了简化WebService 的...

    common-service

    共同服务Clojure库旨在...好的,这取决于您。测验clj -M:test用法整我执照版权所有:copyright:2020 FIXME 该程序和随附的材料根据Eclipse Public License 2.0的条款提供,该条款可从。 当满足Eclipse Public License...

    Angular父子组件以及非父子组件之间的通讯.pdf

    constructor(private commonService: CommonService) { } sendData() { this.commonService.setData('data from A'); } } export class ComponentB implements OnInit { constructor(private commonService: ...

    hibernate链接oracle

    在本篇文章中,我们将深入探讨如何使用Hibernate框架连接Oracle数据库,并通过具体的代码示例来理解整个过程。以下内容将详细解释配置文件中的每一部分及其作用,帮助读者更好地理解和掌握这一技术。 #### 配置数据...

    百度推广API PHP SDK V4_PHP_SDK_20180307

    此时会从CommonService.php里加载默认用户信息,包括url、username、password、token、target、accessToken等。 若想重新设置这些参数,可以执行以下方法: //重设url $service-&gt;setServiceurl("yoururl"); //...

    Neo4J-Mongo-DB-Use-in-Grails:如何在 Neo4j 和 Mongodb 中使用 aspect 复制数据。 以及使用

    Neo4-Mongo-DB-Use-in-Grails 方面是/src/groovy/com/demo/aspects/mongo/history/MongoAspectAdvice.groovy 它调用 CommonService.groovy,它决定了 mongo save 的域类

    angular4 共享服务在多个组件中数据通信的示例

    constructor(private commonService: CommonService) { this.list = commonService.dateList; } ngOnInit() {} } ``` 在这里,我们将`CommonService`添加到`providers`数组中,确保父组件有一个服务实例。同时...

    javaconfig

    JavaConfig是Spring框架中的一种配置方式,它使用Java代码来替代XML配置,使得应用程序的配置更加简洁、可读性更强,同时也更易于测试和...在实际项目中,结合Spring Boot的自动配置,可以构建出简洁而高效的Java应用。

    AngularJs中 ng-repeat指令中实现含有自定义指令的动态html的方法

    在AngularJS中,`ng-repeat`指令用于循环遍历数组或对象,生成DOM元素,它在构建可重用和动态的UI组件时非常有用。在本例中,开发者遇到的问题是在`ng-repeat`循环中包含动态HTML,这些HTML中还嵌套了自定义指令。...

    基于Android平台的教师课堂智能助手系统.pdf

    一、系统架构 该系统主要由三个部分组成:发送端、接收端和蓝牙服务。发送端负责数据的采集和传输,接收端负责数据的接收和处理,蓝牙服务负责蓝牙连接和数据传输。 二、发送端 发送端主要由三个部分组成:...

Global site tag (gtag.js) - Google Analytics