项目第一天(项目框架)
1:项目介绍
参考:《项目分析笔记》和【文档】中的《国家电力系统技术点汇总(简历使用).doc》
2:项目框架(SSH)
第一步:创建数据库(格式:UTF-8)
创建表:
第二步:创建项目(格式:UTF-8)
导入jar包(SSH)
第三步:持久层
(1)在cn.itcast.elec.domain中创建ElecText.java
public class ElecText implements java.io.Serializable {
private String textID; //主键ID
private String textName; //测试名称
private Date textDate; //测试日期
private String textRemark; //测试备注
public String getTextID() {
return textID;
}
public void setTextID(String textID) {
this.textID = textID;
}
public String getTextName() {
return textName;
}
public void setTextName(String textName) {
this.textName = textName;
}
public Date getTextDate() {
return textDate;
}
public void setTextDate(Date textDate) {
this.textDate = textDate;
}
public String getTextRemark() {
return textRemark;
}
public void setTextRemark(String textRemark) {
this.textRemark = textRemark;
}
}
(2)在cn.itcast.elec.domain目录下,创
建ElecText.java对应的映射文件(ElecText.hbm.xml)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="cn.itcast.elec.domain.ElecText" table="Elec_Text">
<id name="textID" type="string" column="textID">
<generator class="uuid"></generator>
</id>
<property name="textName" type="string" column="textName"></property>
<property name="textDate" type="date" column="textDate"></property>
<property name="textRemark" type="string" column="textRemark"></property>
</class>
</hibernate-mapping>
(3)在src下创建hibernate.cfg.xml的配置文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- 连接数据库的信息 -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/itcastElec?useUnicode=true&characterEncoding=utf8</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<!-- 其他的配置 -->
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.show_sql">true</property>
<!-- 加载映射文件 -->
<mapping resource="cn/itcast/elec/domain/ElecText.hbm.xml"/>
</