如何将 build.xml 中定义的变量值传递给 Java 类
请提供一种将 build.xml 中定义的变量值传递给 Java 类的方法
Please provide a way to pass variable value defined in build.xml to Java class
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的构建过程是一回事,您的应用程序运行是另一回事。您无法在运行时将构建参数传递给类。
也许解决您的问题的方法是将
build.xml
中找到的参数写入manifest.mf
,然后在运行时从那里读取它。你可以这样做:
在你的java文件中,看看答案阅读我自己的Jar 的清单。
Your build process is one thing, your app running is another. You can't pass a build parameter to a class at runtime.
Perhaps a solution to your problem would be to write your parameter found in
build.xml
tomanifest.mf
, and then read it from there at runtime.You can do it like this:
And in your java file, take a look at the answer Reading my own Jar's Manifest.
您必须使用 XML 解析器才能做到这一点。阅读此内容以获取更多信息 http://www.java-samples.com/showtutorial。 php?tutorialid=152
You will have to use an XML parser to do that. Read this for more info http://www.java-samples.com/showtutorial.php?tutorialid=152