Java 上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException

Java 上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.BeanCreationException,java,eclipse,spring,maven,spring-mvc,Java,Eclipse,Spring,Maven,Spring Mvc,在Eclipse中成功运行我的Spring启动应用程序(将jason发布到Spring RESTful webservice的示例程序)。但是,当我使用mvn-package命令获取jar文件时。收到以下消息。任何人都可以帮忙 : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationExcept

在Eclipse中成功运行我的Spring启动应用程序(将jason发布到Spring RESTful webservice的示例程序)。但是,当我使用
mvn-package
命令获取jar文件时。收到以下消息。任何人都可以帮忙

: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'controllerSimple' defined in file
ControllerSimple.java

package com.example;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ControllerSimple {

    AddressList addressList;
    ControllerSimple (){
        addressList = new AddressList();
    }



@RequestMapping("/hello")
public String index() {
    return "Hello World";
}  

@RequestMapping(value="/crud_c_final", method=RequestMethod.POST)
public ResponseEntity<AnEntity> create_key(@RequestBody AnEntity anentity) throws SMException, IOException{

    System.out.println("request create received!");
    if(anentity!=null){          
        String key = anentity.getKey();
        String name = anentity.getValue().getName();
        String address = anentity.getValue().getAddress();

...
...
}
pom.xml

<?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>jar</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.3.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
    </dependency>

    <dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
    </dependency>

    <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>jstl</artifactId>
     </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

这是您的主要错误:

Error creating bean with name 'controllerSimple' defined in file [C:\Users\MyPC\workspace\springb\target\classes\com\example\ControllerSimple.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.ControllerSimple]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/poi/util/HexDump
您应该添加更多的Apache POI依赖项:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.14</version>
</dependency>

org.apache.poi
poi
3.14

就快到了。仍然存在一些错误,但要少得多。我已经编辑了帖子,并把错误放在那里。
Error creating bean with name 'controllerSimple' defined in file [C:\Users\MyPC\workspace\springb\target\classes\com\example\ControllerSimple.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.example.ControllerSimple]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/apache/poi/util/HexDump
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.14</version>
</dependency>