Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring application start error: sources must not be empty

Tags:

java

rest

spring

I'm following a 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] o.s.boot.SpringApplication : Starting SpringApplication v1.3.1.RELEASE on ...

2016-01-20 23:18:15.911 INFO 5271 --- [ main] o.s.boot.SpringApplication : No active profile set, falling back to default profiles: default

2016-01-20 23:18:15.918 ERROR 5271 --- [ main] o.s.boot.SpringApplication : Application startup failed java.lang.IllegalArgumentException: Sources must not be empty at org.springframework.util.Assert.notEmpty(Assert.java:276) ~[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:352) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:305) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1124) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] at org.springframework.boot.SpringApplication.main(SpringApplication.java:1140) [spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]

What is this "Sources must not be empty" error?

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

like image 270
Adipati Karna Avatar asked Jan 20 '16 16:01

Adipati Karna


People also ask

Can we run spring boot application without @SpringBootApplication?

It's not mandatory to put @SpringBootApplication to create a Spring Boot application, you can still use @Configuration and @EnableAutoConfiguration individually as shown in the example given in the next point.

What is the entry point of a spring application?

The entry point of the Spring Boot Application is the class contains @SpringBootApplication annotation. This class should have the main method to run the Spring Boot application. @SpringBootApplication annotation includes Auto- Configuration, Component Scan, and Spring Boot Configuration.

What is spring application name in spring boot?

Spring Boot supports YAML based properties configurations to run the application. Instead of application.properties, we can use application.yml file. This YAML file also should be kept inside the classpath. The sample application.yml file is given below − spring: application: name: demoservice server: port: 9090.


1 Answers

It turns out that I did not set the main class correctly in Eclipse - Debug, and Run configuration.

I set org.springframework.boot.SpringApplication as the main class.

The Main class should be pointing to my main class.

like image 109
Adipati Karna Avatar answered Oct 24 '22 00:10

Adipati Karna