Re: Spring Boot Choose Main Class #spring #springboot #java
Ben Hale <bhale@...>
This is more a question for the Spring Boot team, but here's how Spring Boot applications in Cloud Foundry work.
toggle quoted message
Show quoted text
When a Spring Boot application is created, your application is put into `/BOOT-INF` and a "wrapper" application is put into the root of the JAR. The `Main-Class` manifest entry is pointed at one of the Boot launchers (`JarLauncher`, `WarLauncher`, or `PropertiesLauncher`). Then when your application is started via `java -jar app.jar`, that `*Launcher` bootstraps a classpath with everything in `BOOT-INF` and then invokes the value read from the manifest `Start-Class` entry. So the only user of `Start-Class` is Boot itself, not the JVM. In Cloud Foundry we are presented with the exploded JAR file, which makes no difference to how the application is invoked. We create a classpath at the root of the application and invoke the `Main-Class` entry of the manifest (`java -cp . <Main-Class>`) bootstrapping the Boot `*Launcher` as if it had been executed with `java -jar`. At this time, Boot takes over and creates its own internal classloader and invokes `Start-Class` as it would normally do. If you are having an issue where Boot is not invoking the entry in `Start-Class` then that's a question for the Boot team, not Cloud Foundry. -Ben Hale Cloud Foundry Java Lead On Apr 17, 2019, at 07:22, Mrc0113 <marcd@...> wrote: |
|