'could not find or load ${start-class}' when trying this with spring boot pet clinic
See original GitHub issueto reproduce: try out: $ git clone https://github.com/spring-projects/spring-petclinic.git $ cd spring-petclinic $ ./mvnw spring-boot:run
modify pom.xml to include
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>0.1.4</version>
<configuration>
<registry>gcr.io</registry>
<repository>your project/app/repository>
</configuration>
</plugin>
mvnw compile jib:build docker pull and run
see: ‘could not find or load ${start-class}’
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Spring Boot Program cannot find main class - Stack Overflow
I had the same problem. Try this : Right Click the project -> Maven -> Update Project. Then Re-run the project. Hope it...
Read more >Java – “Could Not Find or Load Main Class” Error | Baeldung
Occasionally when we run a Java program, we might see “Could not find or load main class.” It's easy to guess the reason:...
Read more >Java Guide: How to Fix "Could not find or load main class"
The "Could not find or load main class" error occurs when the JVM fails to load the main class. This can happen due...
Read more >Spring Boot Reference Guide
You may want your application to be restarted or reloaded when you make changes to files that are not on the classpath. To...
Read more >Could Not Find or Load Main Class Error | Java - StackChief
This error is very common when creating new Java based projects. Whether you're using Gradle or Maven, Spring Boot or Kafka, chances are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For this, we could either check if the main class we detect is a valid Java class qualifier (something like
([a-z]+\.?)+
), or check explicitly for any${...}
in it (indicating some unresolved Maven property).From https://spring.io/guides/gs/spring-boot/, It looks like Spring Boot Maven plugin searches for the class to run as the main class by looking for a class with
public static void main()
, although it seems that defining astart-class
property is the recommended way (https://www.mkyong.com/spring-boot/spring-boot-which-main-class-to-start/, https://stackoverflow.com/questions/23217002/how-do-i-tell-spring-boot-which-main-class-to-use-for-the-executable-jar/31040641). We could potentially also try looking for a class withpublic static void main()
and use that as the default main class.There is still the problem of when to do the main method search.
If we do the search after inferring from the jar plugin, this issue still happens since Spring boot is actually setting the jar plugin’s main class to
${start-class}
.If we do the search before the jar plugin, we may have the user experience a difference between running their jar and running the jibbed image.
We might still need logic to detect if the main class is a valid java class.