【问题标题】:How to handle 'Rejected bean name - no URL paths identified' in Spring?如何在 Spring 中处理“拒绝的 bean 名称 - 未识别 URL 路径”?
【发布时间】:2015-11-07 09:06:44
【问题描述】:

我有一个 Spring Boot 应用程序,并且在启动时收到以下消息:

7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.internalRequiredAnnotationProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.internalCommonAnnotationProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.internalPersistenceAnnotationProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'application': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor': no URL paths identified
7701 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor': no URL paths identified
7702 [main] DEBUG o.s.w.s.h.BeanNameUrlHandlerMapping - Rejected bean name 'bookingController': no URL paths identified

我在应用中使用的每个 @Autowired 都会发生这种情况。

我的应用程序的唯一配置是:

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

知道为什么我会收到这些消息吗?

在这些消息和其他人说这可能是默认注释处理程序和我没有定义的自定义注释处理程序之间的冲突之后,我尝试使用谷歌搜索。

这些是我的 gradle 依赖项

dependencies {
    compile('org.springframework.boot:spring-boot-autoconfigure')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile("org.springframework.boot:spring-boot-starter-data-rest")
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.6.1')
    compile('org.springframework.boot:spring-boot-starter-security')
    compile("mysql:mysql-connector-java:5.1.34")

    testCompile("junit:junit")
    testCompile("org.springframework.boot:spring-boot-starter-test")
    testCompile("com.jayway.jsonpath:json-path")
    testCompile("com.jayway.jsonpath:json-path-assert:0.9.1")
}

在我的类路径中,我没有任何可能出现这种情况的设置。

【问题讨论】:

  • 我添加了我现在使用的依赖项。
  • 您可以忽略这些消息,如果您查看消息,您看到的只是调试信息。 BeanNameUrlHandlerMapping 查看 bean 的名称并检查该名称是否可以转换为 URL。这些消息仅供您参考,您可以(并且应该)忽略它们,因为您对它们无能为力。您可以禁用调试日志记录,然后您将看不到它们。因此,它与您的依赖关系或它的正常行为无关。
  • 实际上我的应用程序遇到了同样的问题(在调试模式日志中):github.com/vdenotaris/spring-boot-security-saml-sample

标签: spring url spring-boot


【解决方案1】:

正如 cmets 中所说,这是一条调试消息,无需采取任何措施。

对于那些感兴趣的人,这里有一些细节:

在启动时运行HandlerMapping 以确定请求和处理程序对象之间的映射。 AbstractDetectingUrlHandlerMapping 类有一个 detectHandlers 方法,用于注册在当前 ApplicationContext 中找到的所有处理程序。迭代 bean 时,没有标识 URL 路径的 bean 将被拒绝。

这里是对应的code

// Take any bean name that we can determine URLs for.
for (String beanName : beanNames) {
    String[] urls = determineUrlsForHandler(beanName);
    if (!ObjectUtils.isEmpty(urls)) {
        // URL paths found: Let's consider it a handler.
        registerHandler(urls, beanName);
    }
    else {
        if (logger.isDebugEnabled()) {
            logger.debug("Rejected bean name '" + beanName + "': no URL paths identified");
        }
    }
}

【讨论】:

  • 感谢您的回答。我看到了同样的调试消息,因为我把它误认为是请求映射。我仍然迷路,因为我不明白请求映射(在我的控制器上找到)和 URL 映射(BeanNameUrlHandlerMapping 正在寻找而在我的控制器上找不到)之间的区别,您能否链接解释说明的文档区别?因为我没找到。
  • 我认为最好为此提出一个新问题。
  • 谢谢,完成here
猜你喜欢
  • 1970-01-01
  • 2014-02-25
  • 2012-06-08
  • 1970-01-01
  • 2016-08-10
  • 1970-01-01
  • 2020-07-04
  • 2012-10-12
  • 1970-01-01
相关资源
最近更新 更多