この質問はすでに尋ねられており、すべての解決策を確認しましたが、何も役に立たず、まだ同じ問題に直面しています。
Java Config を使用して Spring MVC を使用するように Google Appengine プロジェクトを構成し、Spring のログ レベルを INFO として設定して、初期化ログを確認しました。
これは、初期化時に得られるものです。
14:52:37,885 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'SpringMvcConfig': initialization started
14:52:37,885 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'SpringMvcConfig': initialization started
14:52:37,927 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] - Refreshing WebApplicationContext for namespace 'SpringMvcConfig-servlet': startup date [Sun Sep 08 14:52:37 UTC 2013]; root of context hierarchy
14:52:37,927 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] - Refreshing WebApplicationContext for namespace 'SpringMvcConfig-servlet': startup date [Sun Sep 08 14:52:37 UTC 2013]; root of context hierarchy
14:52:38,087 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14:52:38,087 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14:52:38,093 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] - Successfully resolved class for [com.test.config.SpringMvcConfig]
14:52:38,093 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] - Successfully resolved class for [com.test.config.SpringMvcConfig]
14:52:38,239 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14:52:38,239 INFO [org.springframework.context.annotation.ClassPathBeanDefinitionScanner] - JSR-330 'javax.inject.Named' annotation found and supported for component scanning
14:52:38,826 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
14:52:38,826 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
14:52:38,987 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7fa6e654: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,springMvcConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,mainController,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,requestMappingHandlerMapping,mvcContentNegotiationManager,mvcConversionService,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcValidator,httpRequestHandler Adapter,simpleControllerHandlerAdapter,handlerExceptionResolver,getInternalResourceViewResolver]; root of factory hierarchy
14:52:38,987 INFO [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@7fa6e654: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,springMvcConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,mainController,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,requestMappingHandlerMapping,mvcContentNegotiationManager,mvcConversionService,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcValidator,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,getInternalResourceViewResolver]; root of factory hierarchy
14:52:39,378 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Mapped "{[/ || /login],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto java.lang.String com.test.controller.MainController.hanldeRequest()
14:52:39,378 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Mapped "{[/ || /login],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto java.lang.String com.test.controller.MainController.hanldeRequest()
14:52:39,449 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
14:52:39,449 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler]
14:52:40,355 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'SpringMvcConfig': initialization completed in 2468 ms
14:52:40,355 INFO [org.springframework.web.servlet.DispatcherServlet] - FrameworkServlet 'SpringMvcConfig': initialization completed in 2468 ms
spring mvc は 2 回初期化されます。以下は私の構成です
web.xml
<servlet>
<servlet-name>SpringMvcConfig</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.test.config.SpringMvcConfig
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringMvcConfig</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
私のSpring MVC構成は次のようになります。
@Configuration
@EnableWebMvc
@ComponentScan("com.test.controller")
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false).favorParameter(true).ignoreAcceptHeader(true)
.useJaf(false).defaultContentType(MediaType.APPLICATION_JSON).mediaType("json", MediaType.APPLICATION_JSON);
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(new CustomJacksonObjectMapper());
converters.add(converter);
}
@Bean
public InternalResourceViewResolver getInternalResourceViewResolver() {
InternalResourceViewResolver resolver = new InternalResourceViewResolver();
resolver.setPrefix("/WEB-INF/jsp/");
resolver.setSuffix(".jsp");
resolver.setCache(false);
return resolver;
}
}
誰でもこれを修正するのを手伝ってもらえますか?
解決策や提案は非常に役立ちます。
ありがとう!