作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Hibernate 配置文件 hibernate.cfg.xml
硬编码的属性名称在哪里,例如:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">mysecretpassword</property>
...
</session-factory>
</hibernate-configuration>
.properties
-文件。这样我就会得到以下信息:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.username">${jdbc.username}</property>
<property name="hibernate.connection.password">${jdbc.password}</property>
...
</session-factory>
</hibernate-configuration>
applicationContext.xml
中使用这个:
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
最佳答案
从 hibernate.cfg.xml 中删除配置参数并声明以下内容:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<property name="hibernateProperties">
<value>
hibernate.dialect=${hibernate.dialect}
</value>
</property>
</bean>
关于hibernate - 如何换出 hibernate.cfg.xml 属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3795279/
你好,我目前在 C++ 中有一个很大的代码文件,其中包含许多我经常在不同版本的程序中使用的函数,所以我考虑换掉常用的函数:例如我有: void doSomething(mxArray *in) {
我有一个可以处于两种状态之一的 ListView - 查看和编辑。 在查看状态下,ListView 应该使用一个 View 来呈现行 - 一个具有不可编辑字段的 View 。 在编辑状态下,它应该使用
我正在尝试设置字典 sys.modules,同时正在研究 another question 的答案。并遇到了一些有趣的事情。链接的问题涉及删除导入模块的所有影响。基于another post ,我想到
我正在使用 add_to_swap换出特定页面。然而,即使在我调用了这个返回成功 (1) 的函数之后,显示页表条目 pte_t 的系统仍然存在。 add_to_swap 是换出页面的正确函数还是我应该
我正在努力完成以下任务: 使用 UIButtons 或工具栏交换 UIView 或 Subview 的内容。我有一个如下图所示的 View 。我想通过单击按钮或工具栏上的按钮来换出“要交换的 UIVi
我是一名优秀的程序员,十分优秀!