在IDEA下使用hibernate,删除实体类和对应配置文件后编译,依然会去找那个删除的实体类。然后报错。
使用的编辑器是IDEA,spring集成hibernate
一开始的时候创建了一个实体Usersession,并创建了对应的hibernate映射文件,后来把这个实体删除了,但编译的时候报错,报错如下
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shiroFilter' defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean 'securityManager' while setting bean property 'securityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityManager' defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean 'userRealm' while setting bean property 'realm'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRealm' defined in class path resource [spring/spring-shiro-web.xml]: Cannot resolve reference to bean 'userBiz' while setting bean property 'userBiz'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userBiz' defined in class path resource [spring/spring-beans.xml]: Cannot resolve reference to bean 'userDao' while setting bean property 'userDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in class path resource [spring/spring-beans.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [spring/spring-db.xml]: Invocation of init method failed; nested exception is org.hibernate.boot.MappingException: Error calling Value#setTypeUsingReflection: containingClassName=[
com.yd.taskcat.entity.UserSession], propertyName=[sessionId], role=[com.yd.taskcat.entity.UserSession.sessionId] : origin(null)
我看了一下应该是在spring在生产对应的bean的时候报错,报错最终指向到找不到com.yd.taskcat.entity.UserSession,这个类我确实已经删除了,配置文件也删除了
对应的配置文件:
spring的
<context:property-placeholder location="classpath:db.properties"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean" lazy-init="false">
<!-- 注入datasource,给sessionfactoryBean内setdatasource提供数据源 -->
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<!-- //加载实体类的映射文件位置及名称 -->
<property name="mappingLocations" value="classpath:entity/*.hbm.xml"/>
</bean>
hibernate.cfg.xml中的内容
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
做过尝试将mappingLocations不通过通配符的方式定义,直接指定到具体的.hbm.xml文件,可以避免这个问题,但是后来发现在其他的.hbm.xml增加列没有效果。使用hibernate保存实体的时候新增加的列无法添加。
使用IDEA全局搜索关键字UserSession,没有任何与之相关的内容。
猜测应该是由于什么缓存导致的,在网上找了几个IDEA清缓存的方法都没有效果。
请路过的兄弟也给点意见,提供一些解决思路