Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

服务发现例子中服务提供者的随机端口和预期不一致 #2

Open
listky opened this issue Mar 21, 2023 · 5 comments
Open
Labels
good first issue Good for newcomers question Further information is requested

Comments

@listky
Copy link

listky commented Mar 21, 2023

image

@DerekYRC
Copy link
Owner

@listky 这么诡异的问题哈哈,分支是?

@listky
Copy link
Author

listky commented Mar 21, 2023

分支是服务发现 service-discovery

@DerekYRC
Copy link
Owner

@listky 有趣的问题,server.port配置的端口和tomcat的端口不一致,尚不清楚原因,请教有没有知道的同学

image

@DerekYRC DerekYRC added good first issue Good for newcomers question Further information is requested labels Mar 21, 2023
@2funny
Copy link

2funny commented Mar 30, 2023

应该是服务提供者启动时和@value注入时,都会调用一次RandomValuePropertySource的getRandomValue生成一次随机值导致的问题吧,如果用ApplicationContext.getEnvironment().getProperty(server.port) 测试的话就会发现,每次都会生成一个随机值,想要固定的话,只能手写一个PropertySource了

@DerekYRC
Copy link
Owner

应该是服务提供者启动时和@value注入时,都会调用一次RandomValuePropertySource的getRandomValue生成一次随机值导致的问题吧,如果用ApplicationContext.getEnvironment().getProperty(server.port) 测试的话就会发现,每次都会生成一个随机值,想要固定的话,只能手写一个PropertySource了

@listky @2funny 正确答案,刚debug下确实如此

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants