Windows - 特定环境的私有主机文件
我有一个应用程序在开发服务器上运行并连接到托管 Oracle 实例的开发数据库。
现在我正在 prod/prod-db 机器上部署,
由于 dev-db url 是硬编码在 java 代码中的,所以刚刚复制的二进制文件仍然指向 dev-db。作为快速解决方法,我在 prod 上的 Windows 主机文件中添加了一行,以便 dev-db 现在指向 prod-db IP 地址。这是可行的,但我对这个全球范围的解决方案不太满意。
我想知道是否存在一种方法可以使主机文件在某些环境下“私有”,即。仅在我正在运行的应用程序范围内有效
I've an application running on a dev server and connecting to a dev-db hosting an oracle instance.
Now i'm deploying the on a prod/prod-db machine
Since the dev-db url is hardcoded inside the java code, the just-copied binaries still points to dev-db. As a quick warkaround i added a line in Windows Host file on prod so that dev-db now points to prod-db IP address. It's work, but i'm not very satisfied of this global-scope solution.
I was wondering if exits a way to make a hosts file "private" for a certain environments ie. only valid in the scope of my running application
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,没有办法做到这一点,而且无论如何这都是一个糟糕的方法。
相反,您应该解决真正的问题,即 java 代码中地址的硬编码。将这些内容放入属性文件中,并使用不同的属性文件进行生产。
No, there's no way to do this, and it's a bad approach anyway.
You should instead fix the real problem, which is the hard-coding of the address inside your java code. Put such things in a properties file, and use a different properties file for production.