Skip to content

Commit 4340c41

Browse files
committed
spring-boot-2684 loader: archive main class should fall back to Main-Class attribute if the Start-Class attribute is unavailable
1 parent 2105be2 commit 4340c41

File tree

1 file changed

+6
-2
lines changed
  • spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive

1 file changed

+6
-2
lines changed

spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/archive/Archive.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public abstract class Archive {
4343

4444
/**
4545
* Obtain the main class that should be used to launch the application. By default
46-
* this method uses a {@code Start-Class} manifest entry.
46+
* this method uses a {@code Start-Class} manifest entry and falls back
47+
* to {@code Main-Class} if the former is not found.
4748
* @return the main class
4849
* @throws Exception
4950
*/
@@ -52,10 +53,13 @@ public String getMainClass() throws Exception {
5253
String mainClass = null;
5354
if (manifest != null) {
5455
mainClass = manifest.getMainAttributes().getValue("Start-Class");
56+
if (mainClass == null) {
57+
mainClass = manifest.getMainAttributes().getValue("Main-Class");
58+
}
5559
}
5660
if (mainClass == null) {
5761
throw new IllegalStateException(
58-
"No 'Start-Class' manifest entry specified in " + this);
62+
"No 'Start-Class' nor 'Main-Class' manifest entry specified in " + this);
5963
}
6064
return mainClass;
6165
}

0 commit comments

Comments
 (0)