简体   繁体   English

Windows-特定环境的专用主机文件

[英]Windows - Private hosts file for a certain environment

I've an application running on a dev server and connecting to a dev-db hosting an oracle instance. 我有一个在开发服务器上运行并连接到托管oracle实例的开发数据库的应用程序。

Now i'm deploying the on a prod/prod-db machine 现在,我在prod / prod-db计算机上部署了

Since the dev-db url is hardcoded inside the java code, the just-copied binaries still points to dev-db. 由于dev-db网址是硬编码在Java代码中的,因此刚复制的二进制文件仍指向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. 作为快速解决方法,我在Windows Host文件中的prod上添加了一行,以便dev-db现在指向prod-db IP地址。 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 仅在我正在运行的应用程序范围内有效

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. 相反,您应该解决真正的问题,即Java代码中地址的硬编码。 Put such things in a properties file, and use a different properties file for production. 将此类内容放入属性文件中,并使用其他属性文件进行生产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM