Saturday, 27 July 2019

Spring Boot – How to Change the Default Context Path and port using eclipse Run configurations?

🌟 Elevate Your Coding Skills!

Enjoyed the tutorial? Subscribe to stay ahead with the latest Java and Spring Boot tips!

SUBSCRIBE TO RAM N JAVA

Easily Change Port and Context Path in Eclipse

Are you tired of manually changing application.properties every time you want to test your Spring Boot app on a different port? In this guide, we'll learn how to use Eclipse Run Configurations to make these changes on the fly!

Why Use Eclipse Run Settings?

Eclipse allows you to pass Arguments directly to your application when it starts. This is incredibly useful because:

  • It doesn't change your source code.
  • You can create different "profiles" for different testing scenarios.
  • It saves time by avoiding constant file edits.

Steps to Configure

To set your custom port and path, follow these simple steps:

  1. Right-click your project and select Run As > Run Configurations...
  2. Go to the Arguments tab.
  3. In the VM Arguments box, add your settings like -Dserver.port=9090.
  4. Click Apply and then Run!

Pro Tip for Beginners

Remember that VM Arguments must always start with -D. This tells Java that you are defining a system property that Spring Boot should pick up.


More From Ram N Java:

No comments:

Post a Comment