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

前端 未结 6 930
粉色の甜心
粉色の甜心 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:14

    In your src/main/resources put an application.properties or application.yml and put a server.contextPath in there.

    server.contextPath=/your/context/here
    

    When starting your application the application will be available at http://localhost:8080/your/context/here.

    For a comprehensive list of properties to set see Appendix A. of the Spring Boot reference guide.

    Instead of putting it in the application.properties you can also pass it as a system property when starting your application

    java -jar yourapp.jar -Dserver.contextPath=/your/path/here
    

提交回复
热议问题