我正在尝试启动Spring Boot应用程序,但它无法启动。这是我的堆栈跟踪:
11:27:59.772 [main] DEBUG
org.springframework.boot.devtools.settings.DevToolsSettings - Included
patterns for restart : []
11:27:59.775 [main] DEBUG
org.springframework.boot.devtools.settings.DevToolsSettings - Excluded
patterns for restart : [/spring-boot-starter/target/classes/, /spring-
boot-autoconfigure/target/classes/, /spring-boot-starter-[w-]+/,
/spring-boot/target/classes/, /spring-boot-actuator/target/classes/,
/spring-boot-devtools/target/classes/]
11:27:59.776 [main] DEBUG
org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs
for reloading : [file:/C:/Users/Bobi/Documents/workspace-sts-
3.9.2.RELEASE/springproject/target/classes/]
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.0.M7)
2018-03-18 11:28:00.308 INFO 5048 --- [ restartedMain]
o.s.boot.SpringApplication : Starting SpringApplication
v2.0.0.M7 on DESKTOP-MFS6ORP with PID 5048
(C:UsersBobi.m2repositoryorgspringframeworkbootspring-
boot2.0.0.M7spring-boot-2.0.0.M7.jar started by Bobi in
C:UsersBobiDocumentsworkspace-sts-3.9.2.RELEASEspringproject)
2018-03-18 11:28:00.313 INFO 5048 --- [ restartedMain]
o.s.boot.SpringApplication : No active profile set, falling
back to default profiles: default
2018-03-18 11:28:01.410 ERROR 5048 --- [ restartedMain]
o.s.boot.SpringApplication : Application startup failed
java.lang.IllegalArgumentException: Sources must not be empty
at org.springframework.util.Assert.notEmpty(Assert.java:450) ~[spring-
core-5.0.2.RELEASE.jar:5.0.2.RELEASE]
at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:381) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1245) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
at org.springframework.boot.SpringApplication.main(SpringApplication.java:1261) [spring-boot-2.0.0.M7.jar:2.0.0.M7]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_151]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher
.java:49) [spring-boot-devtools-2.0.0.M7.jar:2.0.0.M7]
这是我的主要课程:
package com.example.a;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App
{
public static void main( String[] args )
{
SpringApplication.run(App.class, args);
}
}
这是我的绒球.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>a</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>a</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
我正在使用Spring工具套件,并通过File->New->Maven项目创建了该项目。我添加了一些依赖项并在主类中添加了SpringApplication.run(App.class, args);
行,仅此而已。 我在StackOverflow上尝试了其他类似的建议,但没有任何效果。我必须执行或更改什么才能使应用程序正确启动?
我解决了这个问题。我不知道我以前是如何运行该项目的,但我只是右键单击>运行如>弹簧启动应用程序,它工作正常。
在 Eclipse 中,当我将其作为 Spring 启动应用程序运行时,它显示了错误,但是当我从右键单击>作为>Java 应用程序运行它时,它完全可以正常工作。