创建名称为'requestMappingHandlerMapping'

时间:2018-10-24 04:41:11

标签: spring spring-boot intellij-idea

我正在使用spring boot和intellij。我遇到错误

  

org.springframework.beans.factory.BeanCreationException:错误   创建名称为“ requestMappingHandlerMapping”的bean   类路径资源   [org / springframework / boot / autoconfigure / web / servlet / WebMvcAutoConfiguration $ EnableWebMvcConfiguration.class]:   调用init方法失败;嵌套异常为   java.lang.ArrayStoreException:   sun.reflect.annotation.TypeNotPresentExceptionProxy在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1694)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractBeanFactory.lambda $ doGetBean $ 0(AbstractBeanFactory.java:317)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:759)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)   〜[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:548)   〜[spring-context-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)   〜[spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]在   org.springframework.boot.SpringApplication.refresh(SpringApplication.java:754)   [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]位于   org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:386)   [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]位于   org.springframework.boot.SpringApplication.run(SpringApplication.java:307)   [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]位于   org.springframework.boot.SpringApplication.run(SpringApplication.java:1242)   [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]位于   org.springframework.boot.SpringApplication.run(SpringApplication.java:1230)   [spring-boot-2.0.6.RELEASE.jar:2.0.6.RELEASE]位于   com.example.demo.DemoApplication.main(DemoApplication.java:10)   [classes /:na]原因:java.lang.ArrayStoreException:   sun.reflect.annotation.TypeNotPresentExceptionProxy在   sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)   〜[na:1.8.0_171]在   sun.reflect.annotation.AnnotationParser.parseArray(AnnotationParser.java:531)   〜[na:1.8.0_171]在   sun.reflect.annotation.AnnotationParser.parseMemberValue(AnnotationParser.java:355)   〜[na:1.8.0_171]在   sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:286)   〜[na:1.8.0_171]在   sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)   〜[na:1.8.0_171]在   sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)   〜[na:1.8.0_171]在   java.lang.Class.createAnnotationData(Class.java:3521)〜[na:1.8.0_171]     在java.lang.Class.annotationData(Class.java:3510)〜[na:1.8.0_171]     在java.lang.Class.createAnnotationData(Class.java:3526)   〜[na:1.8.0_171] at java.lang.Class.annotationData(Class.java:3510)   〜[na:1.8.0_171] at java.lang.Class.getAnnotation(Class.java:3415)   〜[na:1.8.0_171]在   java.lang.reflect.AnnotatedElement.isAnnotationPresent(AnnotatedElement.java:258)   〜[na:1.8.0_171]在   java.lang.Class.isAnnotationPresent(Class.java:3425)〜[na:1.8.0_171]     在   org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:570)   〜[spring-core-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.isHandler(RequestMappingHandlerMapping.java:177)   〜[spring-webmvc-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:218)   〜[spring-webmvc-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:189)   〜[spring-webmvc-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:136)   〜[spring-webmvc-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1753)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE]在   org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1690)   〜[spring-beans-5.0.10.RELEASE.jar:5.0.10.RELEASE] ... 16常见   省略了帧

我的pom.xml文件是

<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd“>     4.0.0

<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>2.0.6.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-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>


    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>

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

演示应用文件

      package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }
}

该项目的github链接是 https://github.com/dishankgoyal/springsBoot/tree/master/demo

0 个答案:

没有答案