0
votes

Recently, I started working on a multi module spring boot gradle project. Am new to gradle and also to the team but I have some experience with Spring boot.

The structute is like Main Project do not contain java files and has only gradle and config info, then its sub project contain spring boot project. While I try to run the project, I get Main Class not found error even though the class exists

I know there must be some configuration done in order to run this but I am unable to identify how to get the details.

This is an old project and no one has any details. Can someone help on how to dig gradle files to get the configuration or atleast start the project?

Edit:

Okay so, I somehow, decided to ignore IDEs and played around with commands. I came to a point that yml files in root folder is not recognized by jar(created from gradle build). as mentioned above, Spring boot project is in child project, where as config(yml files) in root foler.

I added --spring.config.location to java -jar but then understood the jar is generated without dependencies. Any idea how to add them in classpath or build the jar with dependencies?

1
Find @springbootapplication annotated class. Here is main function - GolamMazid Sajib
Okay the sub project has the spring boot application. I am not new to it but the problem is the project while running, is unable to get to the Main Class and throws this error while running from Spring Tool Suite and if executed via intellij, I get Unable to start command '/path to jdk'. - Angellic Doll

1 Answers

0
votes

It actually depends on project, there might not be the main class.

If your project is .jar based:

Gradle multi projects usually have master Gradle module, however, the main class not necessary would be in the main directory.

This could be in another module. If you have Intellij after it finishes indexing project you will see at the top right corner run the class (near green triangle) if you would expand it instead you will be able to see 'Edit configuration ...'.

Then select class, you were seeing before, typically if the project uses Spring Boot there will Spring Boot icon in configuration list on the left.

As soon as you select the class you will have 'Environment tree', there will be field 'Use classpath of Module', you will see the right module for start.


If your project war archive-based:

You won't have any main classes.

As a side note, I advise to check out setup or readme files of the projects.