jdbc配置:
driverClass=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/mydata
user=root
password=root
当数据库中没有mydata表时,无法自动创建,且tomcat启动不了,停留在Initializing Spring root WebApplicationContext。如果手动创建mydata表,tomcat可以启动,项目也能运行。
hibernate配置:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<!-- 数据库言 -->
<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- 加载二级缓存插件(可选) -->
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</property>
<property name="hibernate.cache.use_query_cache">true</property>
<!-- 配置自动生成DDL语句 -->
<property name="hibernate.hbm2ddl.auto">update</property>
<!-- 在控制台打印出当前的sql语句 -->
<property name="hibernate.show_sql">true</property>
<!-- 注册对象关系映射 -->
</session-factory>
tomcat无法启动应该有报错提示,你先看下报错的地址是哪里... 目测可能是连接那边的问题, 然后hibernate那边要配置pojo的package扫描,不然不知道要生成哪些表...
update
改成
drop-create
url=jdbc:mysql://localhost:3306/mydata这里的mydata不是表,而是你要连接哪个数据库,数据库都没建能行??
要是启动没有报错,但是mysql数据库没有创建对应的表是怎么回事啊