我是Spring的新手,在运行简单的Spring Boot Web应用程序时遇到ClassNotFoundException。我已经验证了maven本地存储库,但问题仍然存在。这是我的pom.xml:
<groupId>com.tb</groupId>
<artifactId>igweb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>igweb</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.8.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<tomcat.version>8.5.0</tomcat.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- JSTL tag lib -->
<dependency>
<groupId>javax.servlet.jsp.jstl</groupId>
<artifactId>javax.servlet.jsp.jstl-api</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!-- Tomcat for JSP rendering -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我的主要课程是: 包com.tb.igweb;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class IgwebApplication {
public static void main(String[] args) {
SpringApplication.run(IgwebApplication.class, args);
}
}
在eclipse上运行相同时,我遇到以下异常:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/springframework/util/ClassUtils
at
org.springframework.boot.SpringApplication.deduceWebEnvironment(SpringApplication.java:257)
at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:248)
at org.springframework.boot.SpringApplication.<init>(SpringApplication.java:225)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.tb.igweb.IgwebApplication.main(IgwebApplication.java:10)
Caused by: java.lang.ClassNotFoundException: org.springframework.util.ClassUtils
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more