Spring application launch error: sources should not be empty

I follow the Spring tutorial, and when I tried to start the Spring application, I got the following error:

2016-01-20 23: 18: 15.907 INFO 5271 --- [main] osboot.SpringApplication: launch SpringApplication v1.3.1.RELEASE on ...

2016-01-20 23: 18: 15.911 INFO 5271 --- [primary] osboot.SpringApplication: no active profile, return to default profiles: default

2016-01-20 23: 18: 15.918 ERROR 5271 --- [main] osboot.SpringApplication: application java.lang.IllegalArgumentException failed to start: sources must not be empty org.springframework.util.Assert.notEmpty (Assert.java : 276) ~ [spring -core-4.2.4.RELEASE.jar: 4.2.4.RELEASE] in org.springframework.boot.SpringApplication.doRun (SpringApplication.java{52) [spring -boot-1.3.1.RELEASE .jar: 1.3.1.RELEASE] in org.springframework.boot.SpringApplication.run (SpringApplication.java:305) [spring-boot-1.3.1.RELEASE.jar: 1.3.1.RELEASE] in org.springframework. boot.SpringApplication.run (SpringApplication.java:1124) [spring-boot-1.3.1.RELEASE.jar: 1.3.1.RELEASE] in org.springframework.boot.SpringApplication.main (SpringApplication.java:1140) [spring -boot-1.3.1.RELEASE.jar: 1.3.1.RELEASE]

What is this "Sources should not be empty?"

I am using the Eclipse - Maven project for this tutorial and I updated the project. I also cleaned and rebuilt, but I still have this error.

+6
source share
5 answers

It turns out that I did not set the main class in Eclipse correctly - Debug and Run configuration. I set org.springframework.boot.SpringApplication as the main class. The main class should point to my main class.

+13
source

you must add at least one main configuration class as a source (see attached screenshots).

wrong: enter image description here

right: enter image description here

+5
source

add scanBasePackages = "com.login" to the main class, which will work all your code.

package com.login.example.LoginExample; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication(scanBasePackages="com.login") public class LoginExampleApplication { public static void main(String[] args) { SpringApplication.run(LoginExampleApplication.class, args); } } 
0
source

java.lang.IllegalArgumentException: Sources must not be empty at org.springframework.util.Assert.notEmpty (Assert.java:450) ~ [spring-core-5.0.8.RELEASE.jar: 5.0.8.RELEASE] for the organization .springframework.boot.SpringApplication.prepareContext (SpringApplication.javahaps92) [spring-boot-2.0.4.RELEASE.jar: 2.0.4.RELEASE] in org.springframework.boot.SpringApplication.run (SpringApplication.java:328 ) [spring-boot-2.0.4.RELEASE.jar: 2.0.4.RELEASE] at org.springframework.boot.SpringApplication.run (SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar: 2.0.4.RELEASE] in org.springframework.boot.SpringApplication.main (SpringApplication.java:1274) [spring-boot-2.0.4.RELEASE.jar: 2.0.4.RELEASE]

0
source

If there had been the same problem recently, it turned out that I was managing the wrong Java class. I went to the class where I have the @SpringBootApplication application and right click -> run as a Java application. Maybe this will help someone as stupid as I am.

0
source

Source: https://habr.com/ru/post/1241050/


All Articles