我正在将Spring mvc版本3.2.2与JDBC模板一起使用。 每当我的tomcat重新发布或重新启动时,都会在控制台中生成以下登录信息。
WebApplicationContext 17:04:36,935信息[DefaultListableBeanFactory]销毁org.springframework.beans.factory.support.DefaultListableBeanFactory@20b87b1d中的单例:定义bean [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalorwiredAnnotation .springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,vascularDBConfig,vascularWebAppConfig,org.springframework.context.annotation.ConfigurationClassPostProcessor,进口。 ,vascularExamController,baseDao,demoDao,observationDao,demoService,observationService,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration,org.springframework.transaction.config.internalTran sactionAdvisor,transactionAttributeSource,transactionInterceptor,vascularTransactionManager,namedParameterJdbcTemplate,jdbcTemplate,getDatasource,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,httpRequestHandlerAdapter,mvcConversionService,requestMappingHandlerAdapter,defaultServletHandlerMapping,resourceHandlerMapping,HandlerHandlers,MHandlerHandler,MappingHandler,HandlerHandlers,MappingHandler,HandlerHandlers,MappingHandler,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers,HandlerHandlers。 mvcValidator,setupViewResolver];父级:org.springframework.beans.factory.support.DefaultListableBeanFactory@6a52eeab 17:04:36,935 WARN [DisposableBeanAdapter]在名称为'mvcValidator'的bean上调用销毁方法'close'失败 java.lang.AbstractMethodError:org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.close()V 在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处 在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:606) 在org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:328) 在org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:254) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:510) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:486) 在org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:751) 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:455) 在org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1092) 在org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1066) 在org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1012) 在org.springframework.web.servlet.FrameworkServlet.destroy(FrameworkServlet.java:794) 在org.apache.catalina.core.StandardWrapper.unload(StandardWrapper.java:1482) 在org.apache.catalina.core.StandardWrapper.stopInternal(StandardWrapper.java:1843) 在org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) 在org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5614) 在org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) 在org.apache.catalina.core.StandardContext.reload(StandardContext.java:3947) 在org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426) 在org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1345) 在org.apache.catalina.core.ContainerBase $ ContainerBackgroundProcessor.processChildren(ContainerBase.java:1530) 在org.apache.catalina.core.ContainerBase $ ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 在org.apache.catalina.core.ContainerBase $ ContainerBackgroundProcessor.processChildren(ContainerBase.java:1540) 在org.apache.catalina.core.ContainerBase $ ContainerBackgroundProcessor.run(ContainerBase.java:1519) 在java.lang.Thread.run(Thread.java:744)
下面是我的三个配置类,就像我基于Java的配置一样。
public class Initializer implements WebApplicationInitializer{
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext webApplicationContext = new AnnotationConfigWebApplicationContext();
webApplicationContext.register(DBConfig.class);
webApplicationContext.register(WebAppConfig.class);
webApplicationContext.setServletContext(servletContext);
ServletRegistration.Dynamic dispatcherServlet = servletContext.addServlet("vasculardispatcher", new DispatcherServlet(webApplicationContext));
dispatcherServlet.setLoadOnStartup(1);
dispatcherServlet.addMapping("/rootPath/*");
}
}
@Configuration
@EnableTransactionManagement
@ComponentScan("com")
public class DBConfig {
@Bean
public DataSource getDatasource() {
//my code for getting datasource
}
@Bean
public JdbcTemplate jdbcTemplate() {
JdbcTemplate jdbcTemplate = new JdbcTemplate();
jdbcTemplate.setDataSource(getDatasource());
return jdbcTemplate;
}
@Bean
public NamedParameterJdbcTemplate namedParameterJdbcTemplate() {
return new NamedParameterJdbcTemplate(jdbcTemplate());
}
@Bean(name=TRANSACTION_MANAGER)
public PlatformTransactionManager transactionMngr(){
DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager(getDatasource());
return dataSourceTransactionManager;
}
}
@Configuration
@EnableWebMvc
@ComponentScan("com")
public class WebAppConfig extends WebMvcConfigurerAdapter {
@Bean
public UrlBasedViewResolver setupViewResolver() {
UrlBasedViewResolver viewResolver = new UrlBasedViewResolver();
viewResolver.setOrder(1);
viewResolver.setPrefix("/jsp/");
viewResolver.setSuffix(".jsp");
viewResolver.setViewClass(JstlView.class);
return viewResolver;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SecurityAccessInterceptor());
}
}
有什么想法吗?
答案 0 :(得分:0)
试试validation-api-1.0.0.GA
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>