2016-01-20 39 views
5

我跟隨春天的教程,當我試圖啓動Spring應用程序,我得到了以下錯誤:Spring應用程序啓動錯誤:來源不能爲空

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]

這是什麼「源必須不是空的「錯誤?

我在本教程項目中使用了Eclipse-Maven項目,並且已經更新了項目。我也清理和重建,但我仍然有這個錯誤。

+0

看一看的doRun方法,看看斷言檢查 – Marged

+3

請添加的代碼中的相關部分,讓人們可以提供更多有益的建議。 – betseyb

+0

這可能是由於各地不同版本的Spring庫的髒類路徑導致的。清理它並將它與正確的版本依賴關係對齊到同一個Spring版本。 –

回答

5

事實證明,我沒有在Eclipse - Debug和Run配置中正確設置主類。我將org.springframework.boot.SpringApplication設置爲主類。主班應該指向我的主班。

3

您必須至少添加一個主配置類作爲源(請參閱附加的屏幕截圖)。

錯誤: enter image description here

權: enter image description here

相關問題