我正在Eclipse中创建一个Spring启动应用程序,它现在都是准系统。无法通过Eclipse运行我的Spring启动应用程序
我使用了Spring启动参考指南图示例POM:
<?xml version="1.0" encoding="UTF-8"?>
<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>myproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.4.RELEASE</version>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
接下来,我创建了一个基本Application.java类是这样的:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
而且我这一点,我想只是运行它看看它是否成功,所以我进入运行配置并创建一个目标为“spring-boot:run”的新配置。
但是当我运行它,我得到一个异常: ClassNotFoundException的:org.springframework.boot.SpringApplication
这并没有什么意义,我,因为Eclipse IDE没有显示在类的任何错误表明定位SpringApplication存在问题。
有一点需要注意,我必须做一些特殊的事情才能让我的项目中包含我的Spring Jars,因为我的开发环境无法访问公共Maven回购站我有一个所有这些Jar的本地回购站,并且在项目Build路径的库部分我不得不“指向所有基本的弹簧框架罐”添加变量“让我的项目看到它们。在我做这个之前,它无法找到Eclipse中的罐子。
现在我很困惑,为什么当我运行它时找不到它们?
编辑我注意到的一件事是,当它在\ target文件夹中创建jar时,那里没有lib文件夹,它从不包含我的项目中的jar。
stil gettin运行配置IDE没有检测到主文件。 –