在spring-context.xml和persistence.xml中加载.properties [英] loading .properties in spring-context.xml and persistence.xml

查看:112
本文介绍了在spring-context.xml和persistence.xml中加载.properties的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在spring-context.xml和JPA persistence.xml中引用.properties文件?

我想我在春天的上下文文件中看到了一个这样的例子,尽管我不记得那是哪里了.也许有人知道吗? 关于persistence.xml,我实际上不确定这是否行得通.

我的目标是在开发和发行配置之间更改某些属性. 我目前的想法是通过模板配置中的ant手动替换文件中的所有属性.尽管应该有更好的方法来执行此操作. :)

解决方案

您可以使用 解决方案

You can reference external property files from a Spring bean definition file using a PropertyPlaceholderConfigurer. I don't think that will work for a JPA persistence.xml, although Spring's JPA support allows you to incorporate most, if not all, the content of persistence.xml into the beans file itself, in which case it would work fine.

这篇关于在spring-context.xml和persistence.xml中加载.properties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆