首先搭好框架 例如ssh
然后 applicationContent.xml写上这些
xml version="1.0" encoding="UTF-8"
?>
"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance
"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
">
">
com.pojo
然后 hibernate.cfg.xml里面这样写
xml version="1.0" encoding="UTF-8"
?>
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
" http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd
"
>
org.hibernate.dialect.MySQL5Dialect
我上面两个文件都放在WEBINF下面,但是applicationContext找不到hibernate.cfg
所以我把他们两个都拿出来 然后放到一个resources文件(root)下面
最后在web.xml里面修改applicationContext的位置
<
context-param
>
<
param-name
>
contextConfigLocation
param-name
>
<
param-value
>
classpath:/applicationContext.xml
param-value
>
context-param
>
最后启动下运行就好了(实体类用注解配置,就不在这里说了)