当前位置: 首页 > 知识库问答 >
问题:

org.springframework.beans.factory.BeanCreationExc0019:创建定义了名称为“请求映射句柄映射”的bean时出错

周育
2023-03-14

我正在开发SpringMVC,SpringSecurity示例,在开发这段代码时,我遇到了以下错误:在花了很多天之后,我仍然无法解决这个错误。请尽快引导我。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/MethodIntrospector$MetadataLookup
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:305) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:301) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:835) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537) ~[spring-context-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:446) [spring-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:328) [spring-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) [spring-web-4.2.2.RELEASE.jar:4.2.2.RELEASE]
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5016) [catalina.jar:7.0.59]
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524) [catalina.jar:7.0.59]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [catalina.jar:7.0.59]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575) [catalina.jar:7.0.59]
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565) [catalina.jar:7.0.59]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]

依赖关系树:

[INFO] ------------------------------------------------------------------------
[INFO] Building spring-security-mvc-persisted-remember-me 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ spring-security-mvc-persisted-remember-me ---
[WARNING] The artifact junit:junit-dep:jar:4.11 has been relocated to junit:junit:jar:4.11
[INFO] org.baeldung:spring-security-mvc-persisted-remember-me:war:1.0
[INFO] +- org.springframework.security:spring-security-web:jar:4.0.3.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework.security:spring-security-core:jar:4.0.3.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.2.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-web:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.0.3.RELEASE:compile
[INFO] |  \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-taglibs:jar:4.0.3.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-acl:jar:4.0.3.RELEASE:compile
[INFO] +- org.springframework:spring-orm:jar:4.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:4.2.4.RELEASE:compile
[INFO] +- org.springframework:spring-tx:jar:4.2.4.RELEASE:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- javax.servlet:jstl:jar:1.2:runtime
[INFO] +- com.h2database:h2:jar:1.4.190:compile
[INFO] +- postgresql:postgresql:jar:9.1-901.jdbc4:runtime
[INFO] +- com.google.guava:guava:jar:19.0:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.12:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.1.3:compile
[INFO] |  \- ch.qos.logback:logback-core:jar:1.1.3:compile
[INFO] +- org.slf4j:jcl-over-slf4j:jar:1.7.12:compile
[INFO] +- org.slf4j:log4j-over-slf4j:jar:1.7.12:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] \- org.mockito:mockito-core:jar:1.10.19:test
[INFO]    \- org.objenesis:objenesis:jar:2.1:test
[INFO] ------------------------------------------------------------------------

波姆。xml:

<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>org.baeldung</groupId>
    <artifactId>spring-security-mvc-persisted-remember-me</artifactId>
    <version>1.0</version>
    <name>spring-security-mvc-persisted-remember-me</name>
    <packaging>war</packaging>


    <properties>
        <!-- Spring -->
        <org.springframework.version>4.2.4.RELEASE</org.springframework.version>
        <org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
        <java.version>1.8</java.version>

        <!-- persistence -->
        <hibernate.version>4.3.11.Final</hibernate.version>
        <mysql-connector-java.version>5.1.37</mysql-connector-java.version>
        <h2.version>1.4.190</h2.version>
        <postgresql.version>9.1-901.jdbc4</postgresql.version>


        <!-- logging -->
        <org.slf4j.version>1.7.12</org.slf4j.version>
        <logback.version>1.1.3</logback.version>

        <!-- various -->
        <hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
        <javax.servlet.version>3.0.1</javax.servlet.version>
        <jstl.version>1.2</jstl.version>

        <!-- util -->
        <guava.version>19.0</guava.version>
        <commons-lang3.version>3.4</commons-lang3.version>

        <!-- testing -->
        <org.hamcrest.version>1.3</org.hamcrest.version>
        <junit.version>4.11</junit.version>
        <mockito.version>1.10.19</mockito.version>

        <httpclient.version>4.5</httpclient.version>
        <httpcore.version>4.4.1</httpcore.version>

        <rest-assured.version>2.4.1</rest-assured.version>

        <!-- Maven plugins -->
        <maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
        <maven-war-plugin.version>2.5</maven-war-plugin.version>
        <maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
        <maven-resources-plugin.version>2.7</maven-resources-plugin.version>
        <cargo-maven2-plugin.version>1.4.11</cargo-maven2-plugin.version>

    </properties>

    <dependencies>

        <!-- Spring Security -->

        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${org.springframework.security.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>


        <!-- web -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${javax.servlet.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- persistence -->

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>${h2.version}</version>
        </dependency>

        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${postgresql.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!-- utils -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>


        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
            <!-- <scope>runtime</scope> -->
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>

        <dependency> 
            <groupId>org.slf4j</groupId>
            <artifactId>log4j-over-slf4j</artifactId>
            <version>${org.slf4j.version}</version>
        </dependency>

        <!-- test scoped -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>${org.hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <version>${org.hamcrest.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>spring-security-mvc-persisted-remember-me</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${maven-war-plugin.version}</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <excludes>
                        <!-- <exclude>**/*ProductionTest.java</exclude> -->
                    </excludes>
                    <systemPropertyVariables>
                        <!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>${cargo-maven2-plugin.version}</version>
                <configuration>
                    <wait>true</wait>
                    <container>
                        <containerId>jetty8x</containerId>
                        <type>embedded</type>
                        <systemProperties>
                            <!-- <provPersistenceTarget>cargo</provPersistenceTarget> -->
                        </systemProperties>
                    </container>
                    <configuration>
                        <properties>
                            <cargo.servlet.port>8082</cargo.servlet.port>
                        </properties>
                    </configuration>
                </configuration>
            </plugin>

        </plugins>

    </build>
</project>

共有1个答案

孔逸春
2023-03-14

看起来缺少的类是SpringWebMVC所必需的,它从SpringCoreVersion4.2开始就可用了。3 (https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/core/MethodIntrospector.html),但您使用的是4.2。2.尝试在版本4.2中添加spring core的显式版本。3或尝试更新版本的spring security web 4.0。4.释放。此版本在版本4.2中使用spring core。5.

 类似资料:
  • 名称映射规则 跟名称相关的函数包含在 xorm.io/xorm/names 下。名称映射规则主要负责结构体名称到表名和结构体 field 到表字段的名称映射。由 names.Mapper 接口的实现者来管理,xorm 内置了三种 Mapper 实现:names.SnakeMapper , names.SameMapper和names.GonicMapper。 SnakeMapper 支持struc

  • 很抱歉再次问这种问题,但我无法通过查看其他线程和Spring doc来解决我的问题。 我正在使用maven的3.1.0.RELEASE,并尝试使用注释和java配置。 以下是我的web.xml: 这是我的档案web-application-config.xml. 我有两个类。第一个配置视图解析器 第二个定义我的控制器: 根据我的配置,我想一切都应该指向我的home()函数。然而,事实并非如此,以下

  • 本文向大家介绍JavaScript创建映射,包括了JavaScript创建映射的使用技巧和注意事项,需要的朋友参考一下 示例 映射是键到值的基本映射。映射与对象的不同之处在于,它们的键可以是任何东西(原始值和对象),而不仅仅是字符串和符号。Map上的迭代也总是按照将项目插入Map中的顺序进行,而在对象中的键上进行迭代时,顺序是不确定的。 要创建映射,请使用Map构造函数: 它具有一个可选参数,该参

  • 我正在尝试与我现有的实体建立一些关系。在我的表之间添加几个许多关系之后。在删除我的前一个表格后,Spring建议该id(应与插入=“false”更新=“false”)进行映射。不太确定问题出在哪里 我的实体: 错误

  • 假设我有一组字符串和一个散列函数(或任何单边函数)和一个测试函数。我想用Java8流创建一个从输入字符串到通过测试函数的哈希值的映射。我的问题是如何在中编写? 看来老的for循环是最简洁的解决方案。

  • Web 容器需要本章描述的映射技术去映射客户端请求到 Servlet(该规范2.5以前的版本,使用这些映射技术是作为一个建议而不是要求,允许servlet 容器各有其不同的策略用于映射客户端请求到 servlet)。