??xml version="1.0" encoding="utf-8" standalone="yes"?>
发布web应用E序Ӟ用编译器1.5版本的,q样D了用低版本的jdk去跑了高版本?/font>
jdk~译出来的class文gQ当然报错了QUnsupported major.minor version 49.0Q不
支持L版本?9.0Q?9.0正是jdk1.5的版本号Q?/font>
在myeclispe的解x法:
修改project-->property-->java compiler-->java compliance level 把它调低,?.0-->1.4Q改后自动编译一下,再发布就ok了^_^
package vo;
public class Student {
private int id;
private String name;
public Student(int id, String name) {
super();
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
<?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 package="vo">
<!-- 每个 class 元素映射一个持久化c?-->
<class name="Student" table="student_table">
<!-- 映射标识属?-->
<id name="id">
<!-- 指定主键生成器策?-->
<generator class="identity"/>
</id>
<!-- 映射 name -->
<property name="name"/>
</class>
</hibernate-mapping>
W四步:配置applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/school"/>
<property name="driverClass" value="com.mysql.jdbc.Driver"/>
<property name="user" value="root"/>
<property name="password" value="1234"/>
<property name="maxPoolSize" value="40"/>
<property name="minPoolSize" value="1"/>
<property name="initialPoolSize" value="1"/>
<property name="maxIdleTime" value="20"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="mappingResources">
<list>
<value>vo/student.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.jdbc.batch_size">20</prop>
</props>
</property>
</bean>
</beans>
W五步:配置web.xml (注:主要是ؓ了加载applicationContext.xml而用的)
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
W六步:可以发布项目和q行tomcatQ然后在数据库里可以看到徏成的student_table表了Q是不是很简单啊Q呵呵这只是个简单的入门?br />
注意Q?.在数据库中要先徏好database,我这里是school
2.一些包不要忘记dQ如Qantlr.jar,asm.jar,c3p0.jar,cglib.jar,commoons-beanutils.jar,commons-collection,jar
hibernate3.2.jar,jta.jar,mysql-connector.jar
spring-2.0.jar{等