springboot中设置server.port不生效如何解决

springboot中设置server.port不生效如何解决,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

在配置服务启动的端口时,springboot默认在application.properties配置文件中提供了server.port配置项来

让开发者自行配置服务启动端口号,**但是注意:**

#服务启动端口号
server.port=8889

该配置项要想生效其实是依赖于项目中内嵌的tomcat容器,如下图:

springboot中设置server.port不生效如何解决

内嵌tomcat的jar包依赖包含在pom中

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

如果pom中不引人上述依赖,那么项目中不会导入内嵌tomcat的jar包,相应的application.properties配置文件中server.port配置项也将无法生效

因为该配置项实际上修改的就是内嵌tomcat的web端口号。

springboot server port无法修改

No active profile set, falling back to default profiles: default

经查询发现target\classes文件下,没有生成配置文件。

Build Path -> Configure Build Path... -> java Build Path -> Source

src/main/resources中,

springboot中设置server.port不生效如何解决

将Excluded:** 改为 None

看完上述内容,你们掌握springboot中设置server.port不生效如何解决的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!