1

My question is very simple, how to generate the smallest executable jar package.

I am using the Spring Boot framework, each time you generate executable jar package, the project files and dependencies will be put together all together, resulting in the deployment of the time to upload for a long time, because the file is too big.

Terrence
  • 158
  • 2
  • 4
  • 14

1 Answers1

2

You are using spring-boot-maven-plugin to create fat jar. You can avoid using it however your jar won't be executable, meaning you won't be able to do:

java -jar myapp.jar

The other solution is to extract your fat jar (exploded jar) and for the first deploy upload everything. But next deploy upload only the updated part.

unzip -q myapp.jar -d myapp

And run your app like this:

java -cp myapp org.springframework.boot.loader.JarLauncher

This is how you can do to create Docker image that use efficiently the Docker layer system.

JEY
  • 6,973
  • 1
  • 36
  • 51
  • Okay, I'll try it. – Terrence Apr 19 '17 at 10:05
  • Thank you very much for your way to achieve my idea. But I have another problem, if the operation to ensure that the implementation of the back-end? By adding "&" sign? The The – Terrence Apr 20 '17 at 16:02
  • I didn't quite understand your comment. – JEY Apr 20 '17 at 16:04
  • But when i execute the program, it runs in the foreground. This means that the SSH window is closed and the program is stopped. – Terrence Apr 20 '17 at 16:06
  • It's another problem you could use nohup like nohup java -cp myapp org.springframework.boot.loader.JarLauncher & or use screen. Take a look at http://stackoverflow.com/questions/29142/getting-ssh-to-execute-a-command-in-the-background-on-target-machine don't forget to mark your question as answered – JEY Apr 20 '17 at 16:14