使用CLI使微服务的多个实例在不同端口上侦听的最佳方法/命令是什么?
我试图通过从命令行运行Spring Boot应用程序来运行一个微服务的多个实例。当我从IDE运行一个微服务时,我在控制台上获得以下输出(显示了要向Eureka注册的SBA实例< / p>
Setting initial instance status as: STARTING
Initializing Eureka in region us-east-1
Using JSON encoding codec LegacyJacksonJson
Using JSON decoding codec LegacyJacksonJson
Using XML encoding codec XStreamXml
Using XML decoding codec XStreamXml
Resolving eureka endpoints via configuration
Disable delta property : false
Single vip registry refresh property : null
Force full registry fetch : false
Application is null : false
Registered Applications size is zero : true
Application version is -1: true
Getting all instance registry info from the eureka server
The response status is 200
Starting heartbeat executor: renew interval is: 30
InstanceInfoReplicator onDemand update allowed rate per min is 4
Discovery Client initialized at timestamp 1562346281299 with initial instances count: 2
Registering application XX-PRODUCER with eureka with status UP
现在,我一直在使用标准的-Dserver.port选项以不同的端口号运行SBA,以便使n个SBA实例正常工作。但是,从命令行启动的实例似乎并未向Eureka注册自己,这与我在更改application.properties文件#server.port属性后从IDE运行的实例不同。
D:\x\x>java -jar -Dserver.port=7001 xx-0.1.0.jar
我在运行jar时也尝试添加Eureka端口属性作为选项。
D:\x\x>java -jar -Dserver.port=7001
-Deureka.client.serviceUrl.defaultZone=http://localhost:5000/eureka xx-0.1.0.jar
但是两次,在Eureka上注册的微服务实例的数量仅为1(一个实例是从STS IDE运行的)
D:\x\x>java -jar -Dserver.port=7001
-Deureka.client.serviceUrl.defaultZone=http://localhost:5000/eureka xx-0.1.0.jar
=====/ :: Spring Boot :: (v2.1.6.RELEASE)
2019-07-05 12:03:01.890 INFO 11008 --- [main]
com.xx.xxApplication : Starting xxApplication v1.0 on xx with PID 11008 (xx\xx_0.1.0.jar started by XXX in xx\target)
2019-07-05 12:03:06.060 INFO 11008 ---
[main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 7001 (http)
2019-07-05 12:03:06.217 INFO 11008 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2019-07-05 12:03:06.218
INFO 11008 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.21]
2019-07-05 12:03:06.663
INFO 11008 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2019-07-05 12:03:06.664
INFO 11008
--- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 4501 ms
2019-07-05 12:03:07.688
INFO 11008 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-07-05 12:03:08.513
INFO 11008 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 7001 (http) with context path ''
2019-07-05 12:03:08.525
INFO 11008
--- [main] com.xx.xxApplication : Started xxApplication in 8.392 seconds (JVM running for 9.901)