【发布时间】:2012-03-28 17:00:16
【问题描述】:
我目前正在开发一个中型 Web 项目,使用带有 Spring 的 JSF 2.0。作为 IDE,我使用带有 JBoss 工具的 Eclipse。 Webapp 部署到 Tomcat v7.0 服务器。 我使用 Hibernate/JPA/C3P0/ 连接到数据库(以前是 HyperSQL)我现在尝试切换到 Oracle 数据库,我之前做过很多次,但从来都不是问题,但现在看来,改变了配置只是被忽略了。当我启动服务器时,它仍然使用 HyperSQl 驱动程序和旧数据库,尽管我清理了 Tomcat 的工作目录,删除并重新部署了 Webapp(当然是我从头开始构建的)。 该项目分为两部分,一个 webapp 和一个服务部分。该项目依赖于 Eclipse。然而,虽然所有的业务逻辑都是在服务层实现的,但我可以删除它,webapp 不会抛出错误,我可以启动它,就好像什么都没有改变一样。这告诉我它必须缓存在某个地方并且它没有在服务器上刷新......我还删除了服务器,添加了一个新下载的实例 - 仍然是同样的事情......有没有人知道这可能是什么?
这是我的 service.spring.xml:
<!-- Enable processing of @PersistenceContext and @PersistenceUnit -->
<context:annotation-config/>
<!-- Enable transaction configuration with @Transactional -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- Configure a c3p0 pooled data source -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="user"/>
<property name="password" value="password"/>
<property name="driverClass" value="oracle.jdbc.driver.OracleDriver"/>
<property name="jdbcUrl" value="jdbc:oracle:thin:@dburl"/>
<property name="initialPoolSize" value="1"/>
<property name="minPoolSize" value="1"/>
<property name="maxPoolSize" value="10"/>
</bean>
<!-- Configure the JPA entity manager factory with Hibernate -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="false"/>
<property name="database" value="ORACLE"/>
<property name="generateDdl" value="true"/>
</bean>
</property>
<property name="persistenceUnitName" value="mygourmet"/>
</bean>
<!-- Configure transaction manager for JPA -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
还有我的 persistence.xml:
<persistence-unit name="mygourmet" transaction-type="RESOURCE_LOCAL">
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.OracleDialect" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.use_sql_comments" value="false" />
<property name="hibernate.connection.autocommit" value="false" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.hbm2ddl.auto" value="create" />
</properties>
我在另一个项目中使用了完全相同的配置,它就像一个魅力......任何提示都非常感谢,提前谢谢你们!
【问题讨论】:
-
Tomcat 默认解压你的war文件。你删除了war和解压的文件夹吗?
-
我使用 Eclipse 的 JBOSS tomcat 插件,所以 eclipse 应该会自动处理这个问题,但感谢您的提示!
标签: oracle hibernate jpa hsqldb c3p0