java.lang.NoClassDefFoundError: org/springframework/core/env/ConfigurableEnvironment

后端 未结 7 1445
孤独总比滥情好
孤独总比滥情好 2020-11-27 08:03

I am trying to write a simple RESTful service using Spring Boot. However, there is an error message I am not able to solve. I have been researching and it looks like it is a

相关标签:
7条回答
  • 2020-11-27 08:36

    Recommended Approach

    1. Go to Spring boot Initialzr site and select web stack as a dependency as shown in below .
    2. As Spring Boot uses the concept of Opinionated dependencies and Bill of Materials, It will automatically pull the other dependencies and resolve your classNotFoundException issue. And in your case it misses out the Spring-core-4.2.4.RELEASE.jar dependency.
    3. Execute the Maven Goal as clean install spring-boot:run -e and you can find your maven dependencies in your IDE and below given is a sample POM file.

        <?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>demo</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <packaging>war</packaging>
      
           <name>demo</name>
          <description>Demo project for Spring Boot</description>
      
           <parent>
             <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
           <version>1.4.0.RELEASE</version>
           <relativePath/> <!-- lookup parent from repository -->
         </parent>
      
          <properties>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
             <project.reporting.outputEncoding>UTF-       8</project.reporting.outputEncoding>
          <java.version>1.8</java.version>
          </properties>
      
       <dependencies>
           <dependency>
             <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
      
           <dependency>
                <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-starter-tomcat</artifactId>
                   <scope>provided</scope>
            </dependency>
          <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-actuator</artifactId>
           </dependency>
           <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-starter-test</artifactId>
              <scope>test</scope>
            < /dependency>
          </dependencies>
      
        <build>
          <finalName>demo</finalName>
             <plugins>
               <plugin>
                  <groupId>org.springframework.boot</groupId>
                  <artifactId>spring-boot-maven-plugin</artifactId>
               </plugin>
            </plugins>
          </build>
      

    0 讨论(0)
提交回复
热议问题