1

I would like to reduce the footprint of a fat springboot jar file.

The answer to this question actually covers everything Developing spring boot application with lower footprint

We need to include only the dependencies that we need and do not use auto configuration

My question is:

1- is there anyway (e.g. a script) to list the only used dependencies in a springboot project. i am actually doing trial and error to see if i need a dependency or not.

2- is there anyway to list the AutoConfiguration classes that i have to exclude, i can go and debug to see what springboot is auto configuring and pickup what i dont need, however i am looking for something like a script to check the code and give me a list of the AutoConfiguration classes that i have to exclude.

Gradle is used for dependency management.

user3341697
  • 305
  • 4
  • 12
  • If you have done things right your project should only contain dependencies that you need, else you have done something wrong in your collection of dependencies. To see what has been detected run with `--debug` to get a report. However excluding those classes won't give you much. – M. Deinum Jan 15 '19 at 07:47
  • Do you use Maven or Gradle? – Aritz Jan 15 '19 at 07:52
  • it is gradle @XtremeBiker – user3341697 Jan 15 '19 at 23:14
  • @M.Deinum we use spring-boot starter dependencies, there is nothing wrong, however starter libraries contains too many things, i need to know what is basically is used from the starter dependencies. – user3341697 Jan 15 '19 at 23:16
  • The starters generally only contain what is needed for that piece of software too work with. – M. Deinum Jan 16 '19 at 06:31

1 Answers1

1

If you are using Gradle you can see the full dependency list in a very good and interactive way via command gradle --scan then you can exclude some of the repeated ones.

ksadjad
  • 593
  • 8
  • 20
  • Thanks @kasdjad, the repeated one will be excluded by default when the jar is created, i need something to tell me the unused ones. – user3341697 Jan 16 '19 at 00:03
  • 1
    in that case take a look at https://github.com/nebula-plugins/gradle-lint-plugin/wiki/Unused-Dependency-Rule and also you can see this question here https://stackoverflow.com/questions/19379517/how-to-find-remove-unused-dependencies-in-gradle/33437121 – ksadjad Jan 16 '19 at 07:29