question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'could not find or load ${start-class}' when trying this with spring boot pet clinic

See original GitHub issue

to 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
coollogcommented, Mar 14, 2018
  1. 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).

  2. 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 a start-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 with public static void main() and use that as the default main class.

0reactions
coollogcommented, Mar 22, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found