bean拒绝的原因以及没有标识URL路径意味着什么



我使用的是spring:3.0:我在下面的xml文件中做了一些更改,以更新这个问题。

<servlet>
    <servlet-name>spring</servlet-name>
           <servlet-class>
           org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
      </servlet-mapping>

我有更新的spring-servlet.xml:

    <bean id="localeChangeInterceptor"
            class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
            <property name="paramName" value="lang" />
        </bean>
        <bean id="localeResolver"
            class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
            <property name="defaultLocale" value="en" />
        </bean>
        <bean id="handlerMapping"
            class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
            <property name="interceptors">
                <ref bean="localeChangeInterceptor" />
            </property>
                </bean>
        <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
        <mvc:resources mapping="/images/**"  location="/images/"/>
        <mvc:resources location="/css/**" mapping="/css/"/>
        <mvc:resources location="/css/**" mapping="/css/"/>
        <mvc:default-servlet-handler/>
        <mvc:annotation-driven />
      <context:component-scan base-package="com.dz.hrportal.controller" />
    <bean       class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/jsp/" />
            <property name="suffix" value=".jsp" />
        </bean>
        <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basename" value="classpath:messages" />
            <property name="defaultEncoding" value="UTF-8" />
        </bean>

现在,我的网络应用程序似乎正在运行问题,我可以在服务器日志上看到:

10:48:46,058 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.config.viewControllerHandlerAdapter': no URL paths identified
10:48:46,058 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'abstractController': no URL paths identified
10:48:46,059 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'adminLoginController': no URL paths identified
10:48:46,059 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'empLeaveApplyController': no URL paths identified
10:48:46,059 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'empRegisterController': no URL paths identified
10:48:46,059 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'fileDownloadController': no URL paths identified
10:48:46,059 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'fileUploadController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'globalHomeController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'leaveStatusController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'raiseQueryController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'upComingLeavesController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'viewProfileController': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': no URL paths identified
10:48:46,060 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalRequiredAnnotationProcessor': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalCommonAnnotationProcessor': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'multipartResolver': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.view.InternalResourceViewResolver#0': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'messageSource': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'localeChangeInterceptor': no URL paths identified
10:48:46,061 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'localeResolver': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'handlerMapping': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1': no URL paths identified
10:48:46,062 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#1': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#2': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#2': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#3': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'mailSender': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0': no URL paths identified
10:48:46,063 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'environment': no URL paths identified
10:48:46,064 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'systemProperties': no URL paths identified
10:48:46,064 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'systemEnvironment': no URL paths identified
10:48:46,064 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'servletContext': no URL paths identified
10:48:46,064 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'servletConfig': no URL paths identified
10:48:46,064 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'contextParameters': no URL paths identified
10:48:46,065 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'contextAttributes': no URL paths identified
10:48:46,065 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'importRegistry': no URL paths identified
10:48:46,066 DEBUG BeanNameUrlHandlerMapping:86 - Rejected bean name 'applicationEventMulticaster': no URL paths identified
0:48:46,197 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor': no URL paths identified
10:48:46,197 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalAutowiredAnnotationProcessor': no URL paths identified
10:48:46,197 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalRequiredAnnotationProcessor': no URL paths identified
10:48:46,198 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.internalCommonAnnotationProcessor': no URL paths identified
10:48:46,198 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'multipartResolver': no URL paths identified
10:48:46,198 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.view.InternalResourceViewResolver#0': no URL paths identified
10:48:46,198 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'messageSource': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'localeChangeInterceptor': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'localeResolver': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'handlerMapping': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter#0': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0': no URL paths identified
10:48:46,199 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#1': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#2': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#2': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0': no URL paths identified
10:48:46,200 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#3': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'mailSender': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'environment': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'systemProperties': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'systemEnvironment': no URL paths identified
10:48:46,201 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'servletContext': no URL paths identified
10:48:46,202 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'servletConfig': no URL paths identified
10:48:46,202 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'contextParameters': no URL paths identified
10:48:46,202 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'contextAttributes': no URL paths identified
10:48:46,202 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'importRegistry': no URL paths identified
10:48:46,202 DEBUG DefaultAnnotationHandlerMapping:86 - Rejected bean name 'applicationEventMulticaster': no URL paths identified
0:48:46,313 DEBUG DispatcherServlet:617 - Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@196e136]
10:48:46,313 DEBUG DefaultListableBeanFactory:246 - Returning cached instance of singleton bean 'org.springframework.web.servlet.view.InternalResourceViewResolver#0'
10:48:46,314 DEBUG DispatcherServlet:506 - Published WebApplicationContext of servlet 'spring' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring]
10:48:46,314  INFO DispatcherServlet:446 - FrameworkServlet 'spring': initialization completed in 1126 ms
10:48:46,314 DEBUG DispatcherServlet:136 - Servlet 'spring' configured successfully

为什么bean被拒绝,有人知道解决它的方法吗?

在春季文档中,它说

如果要定义自定义HandlerMappings或HandlerAdapters,则您需要确保相应的自定义DefaultAnnotationHandlerMapping和/或AnnotationMethodHandlerAdapter也被定义了——前提是您打算使用@RequestMapping。

由于您正在定义DefaultAnnotationHandlerMapping,因此还需要定义适配器:

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>

最新更新