Bug report

As title . Following is its reproduce step: 1. set server: port: 8202 in application.yml

  1. together with below dependencies , tomcat start at port 8082 org.springframework.cloud spring-cloud-starter-config 2.1.0.RELEASE
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
                    <version> 2.1.0.RELEASE</version>
    </dependency>
    

I have tried to config server port programmatically when starting applications, or run with -Dserver.port=8202. Both of them are not worked.

But when I take rid of the starter-config dependency , server will start at port 8202.

Could anyone have a suggestion ?

Sincerely Regards.

Comment From: spencergibb

Doesn't make much sense to me unless you are fetching config that has some other server.port configured.

Comment From: 5teven-tian

Doesn't make much sense to me unless you are fetching config that has some other server.port configured.

I am sure that only one place has this configuration. Following is its log : 2019-05-24 10:14:10.045 INFO 26532 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8082 (http)

May TomcatWebServer ignore the user defined value ? I have no idea about the sequence that TomcatWebServer read from.

Comment From: spencergibb

What does /actuator/env say?

Comment From: 5teven-tian

What does /actuator/env say?

As it prints out much information , I just cut part of them about 8082.

{"activeProfiles":["development"],"propertySources":[{"name":"server.ports","properties":{"local.server.port":{"value":8082}}}, "server.port":{"value":"8082"} {"value":"/tmp/tomcat.7165274625889880626.8082"},

Comment From: spencergibb

I don't understand. Is that from when it's working or not working?

Comment From: 5teven-tian

I don't understand. Is that from when it's working or not working?

It is from not working.

I uploaded my config client project may benefit clarifying this issue.

config-client.zip

Comment From: spencergibb

Is Dev tools setting it? I can't look at the project right now

Comment From: 5teven-tian

Is Dev tools setting it? I can't look at the project right now

I use Eclipse to import config-client as Maven project .

Comment From: 5teven-tian

Following is my bootstrap.properties, the port setting is not be read. But others is properly read.

server.port= 8202 spring.application.name = config-client spring.profiles.active=development spring.cloud.config.uri = http://10.4.3.76:8888 management.endpoints.web.exposure.include=*

Comment From: ryanjbaxter

It hard to try your sample since it is missing the config server piece. I don't see anything there that would cause it not to work.

Comment From: 5teven-tian

It hard to try your sample since it is missing the config server piece. I don't see anything there that would cause it not to work.

Because server piece works properly, so I didn't post it.

The problem I meet is "server.port" setting in bootstrap.properties is not recognized by embedded Tomcat server in client side. However , when I write "server.port" setting in application.yml . Tomcat server can recognize it . If I do so , another issue is the setting of Spring Cloud Config not worked in application.yml

Comment From: ryanjbaxter

Again we need a complete working sample to reproduce the problem.

Comment From: spencergibb

A complete sample we can run as a zip file or a repo we can close, not pasted in comments.

Comment From: 5teven-tian

A complete sample we can run as a zip file or a repo we can close, not pasted in comments.

Attached files are server & client project zip. Only source code , no IDE tool settings or binary files.

config-client.zip config-server.zip

Comment From: ryanjbaxter

I cannot run these samples because they assume you are running on windows

Comment From: 5teven-tian

I cannot run these samples because they assume you are running on windows

Following is for Linux ,

server.port = 8888 spring.profiles.active=native spring.cloud.config.server.native.searchLocations=/home/temp

Comment From: spencergibb

When I run your samples I get the following for config client:

2019-06-05 16:38:16.161  INFO 30263 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8202 (http)

Looks like it is running fine on port 8202 from bootstrap.properties

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

Comment From: pabloalencar

I had a similar problem. Cause: I configured SERVER_PORT environment variable, so no matter what you do at "server.port" in application.properties. Solution: remove environment variable (from OS) or set to the port you want.

Reference: https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/howto-embedded-web-servers.html

Hope this can help.