教你搭建SpringMVC框架

  1. 搭建JUnit环境时,测试Controller时,提示“Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.”

    2014-11-3 18:06:46 org.springframework.context.support.FileSystemXmlApplicationContext prepareRefresh
    信息: Refreshing org.[email protected]f81843: startup date [Mon Nov 03 18:06:46 CST 2014]; root of context hierarchy
    2014-11-3 18:06:46 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    信息: Loading XML bean definitions from file [D:\Workspaces\SpringMVCDemo\WebContent\WEB-INF\SpringMVC-servlet.xml]
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-250 ‘javax.annotation.ManagedBean‘ found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.context.annotation.ClassPathBeanDefinitionScanner registerDefaultFilters
    信息: JSR-330 ‘javax.inject.Named‘ annotation found and supported for component scanning
    2014-11-3 18:06:46 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor <init>
    信息: JSR-330 ‘javax.inject.Inject‘ annotation found and supported for autowiring
    2014-11-3 18:06:46 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    信息: Pre-instantiating singletons in org.s[email protected]dda25b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,baseController,testController,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,viewResolver,org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
    ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
    2014-11-3 18:06:46 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping registerHandlerMethod
    信息: Mapped "{[/transfer],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.candy.web.test.TestController.referLogin()
    2014-11-3 18:06:46 org.hibernate.validator.util.Version <clinit>
    信息: Hibernate Validator bean-validator-3.0-JBoss-4.0.2
    2014-11-3 18:06:46 org.springframework.beans.factory.support.DefaultListableBeanFactory destroySingletons
    信息: Destroying singletons in org.s[email protected]dda25b: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,baseController,testController,mvcContentNegotiationManager,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0,org.springframework.format.support.FormattingConversionServiceFactoryBean#0,org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0,org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter#0,org.springframework.web.servlet.handler.MappedInterceptor#0,org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver#0,org.springframework.web.servlet.mvc.annotation.ResponseStatusExceptionResolver#0,org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver#0,org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping,org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter,org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter,viewResolver,org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler#0,org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
    java.lang.ExceptionInInitializerError
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.validation.beanvalidation.LocalValidatorFactoryBean#0‘: Invocation of init method failed; nested exception is javax.validation.ValidationException: Unable to instantiate Configuration.
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1482)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:140)
        at org.springframework.context.support.FileSystemXmlApplicationContext.<init>(FileSystemXmlApplicationContext.java:84)
        at com.candy.web.BaseController.<clinit>(BaseController.java:25)
    Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
        at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:272)
        at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:188)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
        ... 12 more
    Caused by: java.lang.NullPointerException
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:950)
        at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.loadBundle(ResourceBundleMessageInterpolator.java:202)
        at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.getFileBasedResourceBundle(ResourceBundleMessageInterpolator.java:182)
        at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:81)
        at org.hibernate.validator.engine.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:73)
        at org.hibernate.validator.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:57)
        at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:43)
        at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:269)
        ... 15 more
    Exception in thread "main" 

    解决方案:删除JavaEE6中自带的jar包:bean-validator.jar

  2. 如何删除JavaEE6中自带的jar包?
          在MyEclipse的菜单:Window-->Properties-->MyEclipse-->Java Enterprise Project-->Library Sets中,选择到Java EE6.0选项卡(默认选中),然后选择bean-validator.jar,点击右侧的“Remove”按钮,然后点“OK”按钮即可。
  3. ……
  4. ……
时间: 2024-10-06 21:41:41

教你搭建SpringMVC框架的相关文章

教你搭建SpringMVC框架( 更新中、附源码)

搭建JUnit环境时,测试Controller时,提示“Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.” 2014-11-3 18:06:46 org.springframework.context.support.FileSystemXmlApplicationContext prepareRefresh 信息: Refreshing org.[email protect

rapid-framework脚手架快速搭建springMVC框架项目

rapid-framework介绍:   一个类似ruby on rails的java web快速开发脚手架,本着不重复发明轮子的原则,框架只是将零散的struts(struts2)+spring+hibernate各个组件组装好在一起,并对struts及struts2进行改造,提供零配置编程,并内置一个强大的代码生成器及模板文件,可以生成java的hibernat model,dao,manager,struts+struts2 action类,可以生成jsp的增删改查及列表页面.  整个项目

大师养成计划之一:搭建springmvc框架

搭建spring-mvc框架 搭建spring-mvc框架步骤: 1.搭建web项目spring-mvc1 2.引入jar包 3.配置web.xml 3.1拷贝头文件: <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns

基于maven从头搭建springMVC框架

0.准备工作 首先将eclipse和需要的插件准备好,例如maven插件,spring IDE插件. 1.建立maven下的webapp项目 1.新建一个maven项目,类型为webapp,如下图 2.然后给项目命名,加入groupId等 3.配置项目的发布目录,在 Deployment Assemly下,如图 2.配置Spring和Maven 1.配置pom.xml,添加如下包依赖.版本不一定要对应,后边可能会用到些新的包,缺少哪些包可以后续去百度然后加入到pom.xml中 <dependen

手把手教你搭建SpringMVC——最小化配置

为什么需要Spring MVC 最开始接触网页的时候,是纯的html/css页面,那个时候还是用Dreamweaver来绘制页面. 随着网站开发的深入,开始学习servlet开发,记得最痛苦的就是servlet返回网页的内容是字符串拼接的html页面,整不好就无法显示.... 再到后来开学学习SSH,庞大的架构眼花缭乱.Struts繁杂的标签.hibernate搞不清楚的数据表,Spring不知道哪里搞错的bean. 最后随着发展,前端开始占有一席之地,nodejs风生水起,很多业务逻辑开始前置

一步一步教你搭建自动化测试框架——python篇

这两天用python写了一个自动化测试框架,取名为Auty.准备用来做Web方面的接口测试,以下为Auty框架一步一步的搭建过程—— Auty自动化测试框架第一篇——生成执行列表 Auty自动化测试框架第二篇——读取与执行脚本列表 Auty自动化测试框架第三篇——添加异常处理与日志收集 Auty自动化测试框架第四篇——生成测试结果报告 Auty自动化测试框架第五篇——自动化安装库与配置说明

STS搭建springMVC框架(三)

三.创建springMVC项目 1.新建 new --> other -->spring -->spring legacy project   点击next 点击 next 点击Finish,等待加载完成. 因为本地没有引入对应的jar包,项目会有一些错误. 可以继续操作:右键选中项目   2.发布项目 1.tomcat服务器创建及server.xml配置修改 window -->show view --> Servers    打开Servers窗口 在Servers窗口中

STS搭建springMVC框架(一)

一.准备工作 1.JDK 下载地址: http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html 下载1.8(64位)版本 2.STS 下载地址: http://spring.io/tools/sts/all 下载3.9.4(64位)版本 3.Maven    下载地址:http://maven.apache.org/download.cgi 下载最新的3.5.3版本 4.T

STS搭建springMVC框架(二)

二.安装过程 1.JDK  安装JDK: 双击  jdk-8u171-windows-x64.exe 文件,即可开始安装.可以采用默认配置的方式,连续点击下一步直至安装完成. 也可以手动指定安装目录,例如我自己将JDK安装在  D:\Java\jdk1.8.0_171,JRE安装在D:\Java\jre1.8.0_171. 配置环境变量:    ⑴  右键点击计算机图标,接着点击菜单最下方的属性菜单项,或者连续打开控制面板--系统和安全--系统也可以    ⑵  点击高级系统设置--高级--系统