怎么建立网站文件夹,杭州市建设信用网站,wordpress 开发版 视频教程,做网站需要哪些钱spring cloud Eureka集群模式搭建#xff08;IDEA中运行#xff09; 新建springboot 工程工程整体目录配置文件IDEA中部署以jar包形式启动总结 新建springboot 工程
新建一个springboot 工程#xff0c;命名为#xff1a;eureka_server。
其中pom.xml文件为#xff1a; … spring cloud Eureka集群模式搭建IDEA中运行 新建springboot 工程工程整体目录配置文件IDEA中部署以jar包形式启动总结 新建springboot 工程
新建一个springboot 工程命名为eureka_server。
其中pom.xml文件为
?xml version1.0 encodingUTF-8?
project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.didispace/groupIdartifactIdeureka_server/artifactIdversion1.0.0/versionpackagingjar/packagingnameeureka-server/namedescriptionSpring Cloud In Action/descriptionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion1.3.7.RELEASE/versionrelativePath//parentpropertiesproject.build.sourceEncodingUTF-8/project.build.sourceEncodingjava.version1.8/java.version/propertiesdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-eureka-server/artifactId/dependency!--dependency--!--groupIdorg.springframework.boot/groupId--!--artifactIdspring-boot-starter-actuator/artifactId--!--/dependency--/dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversionBrixton.SR5/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementbuildpluginsplugingroupIdorg.springframework.boot/groupIdartifactIdspring-boot-maven-plugin/artifactId/plugin/plugins/build/project项目启动文件为
EnableEurekaServer
SpringBootApplication
public class EurekaServerApplication {public static void main(String[] args) {new SpringApplicationBuilder(EurekaServerApplication.class).web(true).run(args);}
}工程整体目录 配置文件
application-eureka.yml
spring:application:name: eureka-server
server:port: 1111eureka:instance:#eureka服务端的实例名称hostname: eurekaclient:# false表示不向注册中心注册自己register-with-eureka: true# false表示自己端就是注册中心我的职责就是维护服务实例并不需要去检索服务fetch-registry: true#设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址单机。# defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/service-url:defaultZone: http://eureka01:1112/eureka/,http://eureka02:1113/eureka/server:#清理服务间隔3s默认60*10000eviction-interval-timer-in-ms: 3000#关闭自我保护模式enable-self-preservation: false
logging:file: ${spring.application.name}.log
application-eureka01.yml
spring:application:name: eureka-server
server:port: 1112eureka:instance:#eureka服务端的实例名称hostname: eureka01client:# false表示不向注册中心注册自己register-with-eureka: true# false表示自己端就是注册中心我的职责就是维护服务实例并不需要去检索服务fetch-registry: true#设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址单机。# defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/service-url:defaultZone: http://eureka:1111/eureka/,http://eureka02:1113/eureka/server:#清理服务间隔3s默认60*10000eviction-interval-timer-in-ms: 3000#关闭自我保护模式enable-self-preservation: false
logging:file: ${spring.application.name}.log
application-eureka02.yml
spring:application:name: eureka-server
server:port: 1113eureka:instance:#eureka服务端的实例名称hostname: eureka02client:# false表示不向注册中心注册自己register-with-eureka: true# false表示自己端就是注册中心我的职责就是维护服务实例并不需要去检索服务fetch-registry: true#设置与Eureka Server交互的地址查询服务和注册服务都需要依赖这个地址单机。# defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/service-url:defaultZone: http://eureka:1111/eureka/,http://eureka01:1112/eureka/server:#清理服务间隔3s默认60*10000eviction-interval-timer-in-ms: 3000#关闭自我保护模式enable-self-preservation: false
logging:file: ${spring.application.name}.logIDEA中部署
配置文件中的 hostname 和 defaultZone 中设置为别名并修改host文件在文件中添加映射关系如图所示 在IDEA中设置3个启动方式分别启动不同配置文件的工程具体操作如图 点击modify options 选中 program arguments, 输入–spring.profiles.activeeureka 其中–spring.profiles.active是固定写法,eureka是对应yml文件的名字 其他配置文件同理
访问得到的效果如图
以jar包形式启动
java -jar -Dspring.profiles.activeeureka xxx.jar java -jar -Dspring.profiles.activeeureka01 xxx.jar java -jar -Dspring.profiles.activeeureka02 xxx.jar
总结
以上就是最基本spring cloud Eureka集群模式搭建在IDEA中启动与-jar的启动方式希望可以帮助到大家。