我们针对于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架构的搭建过程及如何运用于企业项目。
相关推荐
创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件如下:
创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件如下:
Commonservice-system 是一个大型分布式、微服务、面向企业的 JavaEE 体系快速研发平台,基于模块化、服务化、原子化、热插拔的设计思想,使用成熟领先的无商业限制的主流开源技术构建。 采用服务化的组件开发模式,...
共同服务Clojure库旨在...好的,这取决于您。测验clj -M:test用法整我执照版权所有:copyright:2020 FIXME 该程序和随附的材料根据Eclipse Public License 2.0的条款提供,该条款可从。 当满足Eclipse Public License...
此时会从CommonService.php里加载默认用户信息,包括url、username、password、token、target、accessToken等。 若想重新设置这些参数,可以执行以下方法: //重设url $service->setServiceurl("yoururl"); //...
Neo4-Mongo-DB-Use-in-Grails 方面是/src/groovy/com/demo/aspects/mongo/history/MongoAspectAdvice.groovy 它调用 CommonService.groovy,它决定了 mongo save 的域类
Bean with name ‘commonService’ has been injected into other beans [] in its raw version as part of a circular reference, but has eventually been wrapped. This means that said other beans do not use ...
Interceptors 有两个处理时机,分别是: ... 得到请求的响应之后,在交给其它程序代码处理之前,即处理请求的响应 其引用场景包括 ...commonService.config(['$httpProvider',function($httpProvider){ //$h
应用场景,不同组件中操作统一组数据,不论哪个组件对数据进行了操作,其他组件中立马看到效果。这样他们就要共用一个服务实例,是本次的重点,...export class CommonService { public dateList: any = [ { name:
javaweb项目,目前后台使用springboot mybatis,前端使用vue.js。 原本打算使用dubbo、zookeeper、docker实现微服务框架,但是这个系统功能相对简单,所以暂未实现。 目前所有功能都在commonservice模块。mybatis...
在项目pom.xml里面加入依赖: com.github.hoverruan weiboclient4j 0.4.13 使用 Weiboclient4j支持新浪微博API V1和V2(未完成),目前推荐使用V2版本的接口: // 使用你的应用的api key和secret String ...