Tag: path consolidates data Java state with use. SQL SSM
SSH integrated version
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" > <property Name= "DataSource" ref= "DataSource"/> <property name= "mappingresources" > <list> <value>com/bean/User.hbm.xml</value> </list> </property> <property name= "Hib Ernateproperties "> <props> <prop key=" Hibernate.dialect ">org.hibernate.dialect.mysql5 innodbdialect</prop> <prop key= "Hibernate.show_sql" >true</prop> <prop key= " Hibernate.hbm2ddl.auto ">update</prop> <prop key=" Hibernate.format_sql ">true</prop> </props> </property> </bean>
Modify the Bean class
Among them, class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" caught my attention, because I used the SPRING4, but here there is 3, and changed it into Class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean."
SSM Integrated Edition
Environment is jdk1.8 tomcat8 Spring4
- Item renamed but Pom.xml title part not modified
- is not in the Pom.xml configuration build contains XML, resulting in the target directory without usermapper.xml
- Another situation is that the Mapper scan path in the MyBatis configuration file is not configured
Although the Mapper.xml file has been copied to the class directory, but MyBatis is not loaded, the authentication method is to change the DAO or entity class name in Mapper.xml to a nonexistent name. Generally this is not an error. That's mybatis. The mapper file is not loaded.
The solution is to look inside the MyBatis configuration.
Property Name= "Mapperlocations" value= "Classpath*:com/******/mappers/*mapper.xml" ></property>
is the correct path
I also encountered this problem, just independent with mybatis, not Spring+mybatis, is the registration file order there is a problem
The code has no problems, including namespace, and the Java code is all right
Workaround is
Register all Sqlmap mapping files first
After registering all DAO interface mapper files
For example
<mappers> <mapper resource= "Qh/userreg/userreg.sqlmap.xml"/> <mapper class= " Qh.userreg.IUserRegMapper "/> </mappers>
First
Org.apache.ibatis.binding.BindingException:Invalid bound statement (not found)