springcloud入门_注册中心 博客分类: java
程序员文章站
2024-03-24 10:58:58
...
1.启动注册中心实例
pom.xml
<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> <groupId>com.chry</groupId> <artifactId>springcloud.helloworld.eureka.server</artifactId> <version>0.0.1-SNAPSHOT</version> <name>springcloud.helloworld.Eureka.server</name> <description>Demo Spring Eureka Server</description> <!-- 声明SpringBoot--> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <!-- 统一项目字符集UTF-8 --> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <!--spring cloud eureka server --> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-config</artifactId> </dependency> <!-- spring boot test --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>Dalston.RC1</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> <repositories> <repository> <id>spring-milestones</id> <name>Spring Milestones</name> <url>https://repo.spring.io/milestone</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
注册中心EurekaServerApplication启动类
package springcloud.helloworld.eureka.server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; /** 服务注册 */ @EnableEurekaServer /** 启动 */ @SpringBootApplication /** * * @类描述:EurekaServer实例 * @项目名称:springcloud.helloworld.eureka.server * @包名: springcloud.helloworld.eureka.server * @类名称:EurekaServerApplication * @创建人:wangxuegang * @创建时间:2018年12月19日上午9:47:23 * @mail 15510235102@163.com * @version v1.0 */ public class EurekaServerApplication { public static void main(String[] args) { SpringApplication.run(EurekaServerApplication.class, args); } }
注册中心application.yml配置文件,运行时,去掉注释
# eureka实例端口 server: port: 8761 # eureka注册中心服务器配置 eureka: instance: # eureka实例IP地址 hostname: localhost client: # eureka实例是否注册自己,默认是 true registerWithEureka: false # eureka实例发现注册自己,默认是 true fetchRegistry: false serviceUrl: # 指定eureka注册中心服务器的地址 defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
推荐阅读
-
springcloud入门_注册中心 博客分类: java
-
视频分割项目预研 博客分类: 编程相关Java相关 javaffmpeg入门
-
zip版tomcat(6,7)不能注册成windows服务或者注册后不能启动的问题解决 博客分类: Java其他分类微服务数据库
-
Java加密解密快速入门上篇【包括MD5、BASE64、DES、RSA等算法】 博客分类: Java java加密md5base64安全
-
Mina入门:Java NIO框架Mina、Netty、Grizzly介绍与对比 博客分类: Java NIOmina入门 minanettygrizzlyjava nio框架
-
移动视频: QuickTime for Java API 入门 博客分类: RTSPjava
-
RabbitMQ 入门 Helloworld 博客分类: 消息队列java RabbitMQHelloworld
-
hazelcast入门实例 博客分类: Java hazelcastmemorydistributedgridcompute
-
redis作为dubbo服务的注册中心 博客分类: redis redis
-
数据库基础入门(四)— — 产品功能实现之数据库架构与用户登录注册 博客分类: 数据库相关 数据库产品架构用户登录用户注册sql