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:
Directory Structure: Ensure your structure looks like this:
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 :).