2

Good day,

I am doing a Spring Boot Application in my Eclipse IDE. When I right click on my SpringBoot Application file and run as Java application, I hitting error as follow:


APPLICATION FAILED TO START


Description:

Field tutorialRepository in com.utility.tool.ToolApplication required a bean of type 'com.utility.tool.repository.TutorialRepository' that could not be found.

The injection point has the following annotations:
        - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'com.utility.tool.repository.TutorialRepository' in your configuration.

Then I found that I forget to include the spring boot starter data jar. Hence, I add the following code in my build.gradle and it finally run correctly:

implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.5'

Then I right click my project and export jar as runnable jar, and then try to run it by java -jar my.jar, and it hit back the error.

I open the jar in JdGui, and found that the spring-boot-starter-data-jpa-2.7.5.jar is inside. May I know what is my mistake? My jar structure is something as follow:

enter image description here

The jar is in the list but is at bottom, thus not in my screen shot.

Panadol Chong
  • 1,793
  • 13
  • 54
  • 119
  • 1
    Not sure how you made that jar but that isn't a proper Spring Boot jar. Use the build tool you are using (maven or gradle) to provide the jar not the export to jar functionin your IDE. – M. Deinum Nov 15 '22 at 10:45
  • @M.Deinum I am using gradle, any place I can get a sample for Spring Boot? – Panadol Chong Nov 15 '22 at 12:06
  • Check the documentaiton, just do `./gradlew build` and the resulting jar is the correct one. – M. Deinum Nov 15 '22 at 12:14
  • thanks @M.Deinum, u are right. its actually just simple gradle build will generate the jar correctly. At first need tricky job on it. – Panadol Chong Nov 15 '22 at 14:38

1 Answers1

0

Check your SpringBoot annotations. You may be missing some @Service, @Repository, @Component annotations.

jjmontes
  • 24,679
  • 4
  • 39
  • 51
Jatel
  • 40
  • 8