如何在 Spring 中处理“拒绝的 bean 名称 - 未识别 URL 路径”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33581039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to handle 'Rejected bean name - no URL paths identified' in Spring?
提问by tzortzik
I have a Spring Boot Application and I get at launch time the following messages:
我有一个 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
This is happening for every @Autowired
I have used in my app.
@Autowired
我在我的应用程序中使用过的每一个都会发生这种情况。
The only configuration for my application is:
我的应用程序的唯一配置是:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Any ideas why I get those messages?
知道为什么我会收到这些消息吗?
I tried to google after those messages and others said that it may be a conflict between the default annotation handler and custom annotation handler which I have not defined.
我在这些消息之后尝试用谷歌搜索,其他人说这可能是默认注释处理程序和我尚未定义的自定义注释处理程序之间的冲突。
Those are my gradle dependencies
这些是我的 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.Hymanson.datatype:Hymanson-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")
}
In my classpath I don't have any settings which may case this.
在我的类路径中,我没有任何可能会导致这种情况的设置。
回答by Ortomala Lokni
As said in the comments, this is a debug message and no actions need to be taken.
正如评论中所说,这是一条调试消息,无需采取任何措施。
For those interested, here are some details:
对于感兴趣的人,这里有一些细节:
At startup a HandlerMappingis run to determine a mapping between requests and handler objects. The AbstractDetectingUrlHandlerMappingclass has a detectHandlersmethod that register all handlers found in the current ApplicationContext. When iterating over beans, the beans for which no URL paths are identified, are rejected.
在启动时运行HandlerMapping以确定请求和处理程序对象之间的映射。该AbstractDetectingUrlHandlerMapping类有一个detectHandlers方法是注册在当前ApplicationContext中发现的所有处理程序。在对 bean 进行迭代时,未识别出 URL 路径的 bean 将被拒绝。
Here is the corresponding 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");
}
}
}