79508216

Date: 2025-03-14 05:30:58
Score: 1
Natty:
Report link

To run a Spring Boot 3 fat JAR with external libraries in a lib directory and configuration files in a config directory, follow these steps:

  1. Directory Structure: Ensure your structure looks like this:

    enter image description here

  2. Run the Application: Use the following command to start your application, ensuring to include the external libraries and configuration folder:

    java -cp "MyApp.jar:lib/*" org.springframework.boot.loader.WarLauncher --spring.config.additional-location=file:./config/

    Explanation:

    • -cp "MyApp.jar:lib/*": Sets the classpath to include your JAR and all JARs in the lib folder.

    • --spring.config.additional-location=file:./config/: Tells Spring to load configuration files from the config directory.

    Make sure to adjust the path separator if you're on Windows (; instead of :).

Reasons:
  • Blacklisted phrase (1): enter image description here
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Sarwar Miral