整理大象ssh全注解架构遇到的有关问题

整理大象ssh全注解架构遇到的问题

按照大象的文章开始配置ssh架构,但是由于版本不相近遇到了两个问题,特此记录下

1.java.lang.NoSuchFieldError: INSTANCEat org.hibernate.type.BasicTypeRegistry.<init>(BasicTypeRegistry.java:94)at org.hibernate.type.TypeResolver.<init>(TypeResolver.java:59)at org.hibernate.cfg.Configuration.<init>(Configuration.java:249)at org.hibernate.cfg.Configuration.<init>(Configuration.java:300)

经过查找发现是hibernate-annotations.jar和hibernate-commons-annotations.jar的问题,hibernate.jar已经将其整合

2.去掉两个包之后出现Error creating bean with name 'userManager': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bolo.examples.dao.base.UserDao com.bolo.examples.service.base.UserManager.userDao; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [E:\MyEclipse9.0\workspace\ssh2\WebRoot\WEB-INF\classes\com\bolo\examples\dao\base\UserDao.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory

 

也是一番查找之后发现在

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource" ref="dataSource" />
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <prop key="javax.persistence.validation.mode">none</prop>
   </props>
  </property>
  <property name="packagesToScan" value="com.bolo.examples.entity.*" />
 </bean>

 

加入红色部分就没有问题了

 

真是不同的版本差异比较大啊

我当前的版本struts2.3.3 spring3.06 hibernate3.6.7-Final release

大象的版本   struts2.1.6 spring2.56 hibernate3.3.1


我的异常网推荐解决方案:org.springframework.beans.factory.BeanCreationException:,http://www..net/j2ee/10759.html