How do I choose the URL for my Spring Boot webapp?

前端 未结 6 944
粉色の甜心
粉色の甜心 2020-11-30 03:48

I am using Spring Boot to create a web app, and I am not sure how to change the URL from localhost:8080 to something like localhost:8080/myWebApp.

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 04:01

    The server.contextPath or server.context-path works if

    in pom.xml

    1. packing should be war not jar
    2. Add following dependencies

      
          org.springframework.boot
           spring-boot-starter-web
      
      
       
           org.springframework.boot
          spring-boot-starter-tomcat
          provided
       
      

      In eclipse, right click on project --> Run as --> Spring Boot App.

提交回复
热议问题